@prosekit/extensions 0.12.2 → 0.14.0

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 (324) hide show
  1. package/dist/{drop-indicator-B1QHFb5m.js → drop-indicator-B_oMfeVP.js} +11 -10
  2. package/dist/drop-indicator-B_oMfeVP.js.map +1 -0
  3. package/dist/{enter-rule-CzWOZF_Z.js → enter-rule-D-p4ykfv.js} +1 -1
  4. package/dist/enter-rule-D-p4ykfv.js.map +1 -0
  5. package/dist/{file-DrfcSid-.js → file-iLVR0eM0.js} +3 -3
  6. package/dist/file-iLVR0eM0.js.map +1 -0
  7. package/dist/{index-oIc1a2f2.d.ts → index-cp1u4e0e.d.ts} +1 -1
  8. package/dist/index-cp1u4e0e.d.ts.map +1 -0
  9. package/dist/{input-rule-dmsb3j6w.js → input-rule-COGr_GBb.js} +1 -1
  10. package/dist/input-rule-COGr_GBb.js.map +1 -0
  11. package/dist/list/style.css +5 -5
  12. package/dist/list/style.css.map +1 -1
  13. package/dist/{mark-rule-BcLB4Uv2.js → mark-rule-CYe8zk4q.js} +6 -6
  14. package/dist/mark-rule-CYe8zk4q.js.map +1 -0
  15. package/dist/{paste-rule-pVb4sqvJ.js → paste-rule-BaDghcaU.js} +7 -7
  16. package/dist/paste-rule-BaDghcaU.js.map +1 -0
  17. package/dist/prosekit-extensions-autocomplete.d.ts +11 -3
  18. package/dist/prosekit-extensions-autocomplete.d.ts.map +1 -1
  19. package/dist/prosekit-extensions-autocomplete.js +171 -60
  20. package/dist/prosekit-extensions-autocomplete.js.map +1 -1
  21. package/dist/prosekit-extensions-background-color.d.ts +62 -0
  22. package/dist/prosekit-extensions-background-color.d.ts.map +1 -0
  23. package/dist/prosekit-extensions-background-color.js +76 -0
  24. package/dist/prosekit-extensions-background-color.js.map +1 -0
  25. package/dist/prosekit-extensions-blockquote.d.ts.map +1 -1
  26. package/dist/prosekit-extensions-blockquote.js +2 -2
  27. package/dist/prosekit-extensions-blockquote.js.map +1 -1
  28. package/dist/prosekit-extensions-bold.d.ts.map +1 -1
  29. package/dist/prosekit-extensions-bold.js +1 -1
  30. package/dist/prosekit-extensions-bold.js.map +1 -1
  31. package/dist/prosekit-extensions-code-block.d.ts +1 -1
  32. package/dist/prosekit-extensions-code-block.d.ts.map +1 -1
  33. package/dist/prosekit-extensions-code-block.js +4 -4
  34. package/dist/prosekit-extensions-code-block.js.map +1 -1
  35. package/dist/prosekit-extensions-code.d.ts.map +1 -1
  36. package/dist/prosekit-extensions-code.js +1 -1
  37. package/dist/prosekit-extensions-code.js.map +1 -1
  38. package/dist/prosekit-extensions-commit.d.ts +0 -1
  39. package/dist/prosekit-extensions-commit.d.ts.map +1 -1
  40. package/dist/prosekit-extensions-commit.js +1 -1
  41. package/dist/prosekit-extensions-commit.js.map +1 -1
  42. package/dist/prosekit-extensions-doc.d.ts +0 -1
  43. package/dist/prosekit-extensions-doc.d.ts.map +1 -1
  44. package/dist/prosekit-extensions-doc.js.map +1 -1
  45. package/dist/prosekit-extensions-drop-cursor.d.ts.map +1 -1
  46. package/dist/prosekit-extensions-drop-cursor.js.map +1 -1
  47. package/dist/prosekit-extensions-drop-indicator.d.ts +0 -1
  48. package/dist/prosekit-extensions-drop-indicator.d.ts.map +1 -1
  49. package/dist/prosekit-extensions-drop-indicator.js +1 -1
  50. package/dist/prosekit-extensions-enter-rule.d.ts +0 -1
  51. package/dist/prosekit-extensions-enter-rule.d.ts.map +1 -1
  52. package/dist/prosekit-extensions-enter-rule.js +1 -1
  53. package/dist/prosekit-extensions-file.d.ts +1 -1
  54. package/dist/prosekit-extensions-file.js +1 -1
  55. package/dist/prosekit-extensions-gap-cursor.d.ts +0 -1
  56. package/dist/prosekit-extensions-gap-cursor.d.ts.map +1 -1
  57. package/dist/prosekit-extensions-gap-cursor.js.map +1 -1
  58. package/dist/prosekit-extensions-hard-break.d.ts.map +1 -1
  59. package/dist/prosekit-extensions-hard-break.js.map +1 -1
  60. package/dist/prosekit-extensions-heading.d.ts.map +1 -1
  61. package/dist/prosekit-extensions-heading.js +7 -7
  62. package/dist/prosekit-extensions-heading.js.map +1 -1
  63. package/dist/prosekit-extensions-horizontal-rule.d.ts.map +1 -1
  64. package/dist/prosekit-extensions-horizontal-rule.js +1 -1
  65. package/dist/prosekit-extensions-horizontal-rule.js.map +1 -1
  66. package/dist/prosekit-extensions-image.d.ts +9 -2
  67. package/dist/prosekit-extensions-image.d.ts.map +1 -1
  68. package/dist/prosekit-extensions-image.js +17 -4
  69. package/dist/prosekit-extensions-image.js.map +1 -1
  70. package/dist/prosekit-extensions-input-rule.d.ts +0 -1
  71. package/dist/prosekit-extensions-input-rule.d.ts.map +1 -1
  72. package/dist/prosekit-extensions-input-rule.js +1 -1
  73. package/dist/prosekit-extensions-italic.d.ts.map +1 -1
  74. package/dist/prosekit-extensions-italic.js +1 -1
  75. package/dist/prosekit-extensions-italic.js.map +1 -1
  76. package/dist/prosekit-extensions-link.d.ts +0 -1
  77. package/dist/prosekit-extensions-link.d.ts.map +1 -1
  78. package/dist/prosekit-extensions-link.js +4 -4
  79. package/dist/prosekit-extensions-link.js.map +1 -1
  80. package/dist/prosekit-extensions-list.d.ts +0 -1
  81. package/dist/prosekit-extensions-list.d.ts.map +1 -1
  82. package/dist/prosekit-extensions-list.js +3 -3
  83. package/dist/prosekit-extensions-list.js.map +1 -1
  84. package/dist/prosekit-extensions-loro.d.ts +16 -17
  85. package/dist/prosekit-extensions-loro.d.ts.map +1 -1
  86. package/dist/prosekit-extensions-loro.js +14 -7
  87. package/dist/prosekit-extensions-loro.js.map +1 -1
  88. package/dist/prosekit-extensions-mark-rule.d.ts +0 -1
  89. package/dist/prosekit-extensions-mark-rule.d.ts.map +1 -1
  90. package/dist/prosekit-extensions-mark-rule.js +1 -1
  91. package/dist/prosekit-extensions-mention.d.ts.map +1 -1
  92. package/dist/prosekit-extensions-mention.js.map +1 -1
  93. package/dist/prosekit-extensions-mod-click-prevention.d.ts +0 -1
  94. package/dist/prosekit-extensions-mod-click-prevention.d.ts.map +1 -1
  95. package/dist/prosekit-extensions-mod-click-prevention.js.map +1 -1
  96. package/dist/prosekit-extensions-paragraph.d.ts.map +1 -1
  97. package/dist/prosekit-extensions-paragraph.js +1 -1
  98. package/dist/prosekit-extensions-paragraph.js.map +1 -1
  99. package/dist/prosekit-extensions-paste-rule.d.ts +0 -1
  100. package/dist/prosekit-extensions-paste-rule.d.ts.map +1 -1
  101. package/dist/prosekit-extensions-paste-rule.js +1 -1
  102. package/dist/prosekit-extensions-placeholder.d.ts.map +1 -1
  103. package/dist/prosekit-extensions-placeholder.js +3 -4
  104. package/dist/prosekit-extensions-placeholder.js.map +1 -1
  105. package/dist/prosekit-extensions-readonly.d.ts +0 -1
  106. package/dist/prosekit-extensions-readonly.d.ts.map +1 -1
  107. package/dist/prosekit-extensions-readonly.js.map +1 -1
  108. package/dist/prosekit-extensions-search.d.ts +0 -1
  109. package/dist/prosekit-extensions-search.d.ts.map +1 -1
  110. package/dist/prosekit-extensions-search.js.map +1 -1
  111. package/dist/prosekit-extensions-strike.d.ts +0 -1
  112. package/dist/prosekit-extensions-strike.d.ts.map +1 -1
  113. package/dist/prosekit-extensions-strike.js +3 -3
  114. package/dist/prosekit-extensions-strike.js.map +1 -1
  115. package/dist/prosekit-extensions-table.d.ts.map +1 -1
  116. package/dist/prosekit-extensions-table.js +1 -2
  117. package/dist/prosekit-extensions-text-align.d.ts +0 -1
  118. package/dist/prosekit-extensions-text-align.d.ts.map +1 -1
  119. package/dist/prosekit-extensions-text-align.js +6 -6
  120. package/dist/prosekit-extensions-text-align.js.map +1 -1
  121. package/dist/prosekit-extensions-text-color.d.ts +62 -0
  122. package/dist/prosekit-extensions-text-color.d.ts.map +1 -0
  123. package/dist/prosekit-extensions-text-color.js +76 -0
  124. package/dist/prosekit-extensions-text-color.js.map +1 -0
  125. package/dist/prosekit-extensions-text.d.ts +0 -1
  126. package/dist/prosekit-extensions-text.d.ts.map +1 -1
  127. package/dist/prosekit-extensions-text.js.map +1 -1
  128. package/dist/prosekit-extensions-underline.d.ts +0 -1
  129. package/dist/prosekit-extensions-underline.d.ts.map +1 -1
  130. package/dist/prosekit-extensions-virtual-selection.d.ts +0 -1
  131. package/dist/prosekit-extensions-virtual-selection.d.ts.map +1 -1
  132. package/dist/prosekit-extensions-virtual-selection.js.map +1 -1
  133. package/dist/prosekit-extensions-yjs.d.ts +9 -2
  134. package/dist/prosekit-extensions-yjs.d.ts.map +1 -1
  135. package/dist/prosekit-extensions-yjs.js +1 -1
  136. package/dist/prosekit-extensions-yjs.js.map +1 -1
  137. package/dist/{shiki-highlighter-chunk-rkzofy4z.d.ts → shiki-highlighter-chunk-DNNm2Vow.d.ts} +1 -1
  138. package/dist/shiki-highlighter-chunk-DNNm2Vow.d.ts.map +1 -0
  139. package/dist/shiki-highlighter-chunk.d.ts +1 -1
  140. package/dist/shiki-highlighter-chunk.js.map +1 -1
  141. package/dist/{table-BRDh_9mG.js → table-4oHfV-Ql.js} +2 -2
  142. package/dist/table-4oHfV-Ql.js.map +1 -0
  143. package/package.json +33 -18
  144. package/src/autocomplete/autocomplete-helpers.ts +19 -14
  145. package/src/autocomplete/autocomplete-plugin.ts +260 -126
  146. package/src/autocomplete/autocomplete-rule.ts +3 -3
  147. package/src/autocomplete/autocomplete.spec.ts +244 -40
  148. package/src/autocomplete/autocomplete.ts +9 -7
  149. package/src/background-color/background-color-commands.spec.ts +71 -0
  150. package/src/background-color/background-color-commands.ts +35 -0
  151. package/src/background-color/background-color-spec.spec.ts +286 -0
  152. package/src/background-color/background-color-spec.ts +58 -0
  153. package/src/background-color/background-color.ts +21 -0
  154. package/src/background-color/index.ts +8 -0
  155. package/src/blockquote/blockquote-commands.ts +1 -7
  156. package/src/blockquote/blockquote-keymap.spec.ts +5 -9
  157. package/src/blockquote/blockquote-keymap.ts +2 -7
  158. package/src/blockquote/blockquote-spec.ts +1 -4
  159. package/src/blockquote/blockquote.ts +3 -12
  160. package/src/blockquote/index.ts +3 -12
  161. package/src/bold/bold-commands.ts +1 -5
  162. package/src/bold/bold-input-rule.spec.ts +1 -5
  163. package/src/bold/bold-input-rule.ts +1 -4
  164. package/src/bold/bold-keymap.ts +1 -5
  165. package/src/bold/bold-spec.ts +1 -4
  166. package/src/bold/bold.ts +3 -12
  167. package/src/bold/index.ts +3 -12
  168. package/src/code/code-commands.ts +1 -5
  169. package/src/code/code-input-rule.ts +1 -4
  170. package/src/code/code-keymap.ts +1 -5
  171. package/src/code/code-spec.ts +1 -4
  172. package/src/code/code.ts +3 -12
  173. package/src/code/index.ts +3 -12
  174. package/src/code-block/code-block-commands.ts +1 -8
  175. package/src/code-block/code-block-highlight.ts +2 -8
  176. package/src/code-block/code-block-keymap.ts +2 -9
  177. package/src/code-block/code-block-shiki.ts +1 -4
  178. package/src/code-block/code-block-spec.spec.ts +4 -11
  179. package/src/code-block/code-block-spec.ts +1 -4
  180. package/src/code-block/code-block.ts +4 -16
  181. package/src/code-block/index.ts +5 -21
  182. package/src/code-block/shiki-highlighter-chunk.ts +1 -7
  183. package/src/code-block/shiki-highlighter.ts +1 -4
  184. package/src/code-block/shiki-parser.ts +1 -4
  185. package/src/commit/index.ts +7 -36
  186. package/src/doc/index.ts +1 -4
  187. package/src/drop-cursor/drop-cursor.ts +1 -4
  188. package/src/drop-cursor/index.ts +1 -5
  189. package/src/drop-indicator/drop-indicator-facet.ts +12 -21
  190. package/src/drop-indicator/index.ts +1 -5
  191. package/src/enter-rule/index.ts +2 -11
  192. package/src/file/file-paste-handler.spec.ts +3 -16
  193. package/src/file/index.ts +3 -16
  194. package/src/gap-cursor/gap-cursor.ts +1 -4
  195. package/src/gap-cursor/index.ts +1 -4
  196. package/src/hard-break/hard-break-commands.ts +1 -5
  197. package/src/hard-break/hard-break-keymap.spec.ts +6 -12
  198. package/src/hard-break/hard-break-keymap.ts +1 -4
  199. package/src/hard-break/hard-break-spec.ts +1 -4
  200. package/src/hard-break/hard-break.ts +3 -12
  201. package/src/hard-break/index.ts +3 -12
  202. package/src/heading/heading-commands.ts +1 -7
  203. package/src/heading/heading-keymap.spec.ts +8 -12
  204. package/src/heading/heading-keymap.ts +7 -14
  205. package/src/heading/heading-spec.ts +1 -4
  206. package/src/heading/heading.ts +3 -12
  207. package/src/heading/index.ts +3 -12
  208. package/src/horizontal-rule/horizontal-rule-commands.spec.ts +1 -5
  209. package/src/horizontal-rule/horizontal-rule-commands.ts +2 -9
  210. package/src/horizontal-rule/horizontal-rule-input-rule.spec.ts +5 -9
  211. package/src/horizontal-rule/horizontal-rule-input-rule.ts +1 -5
  212. package/src/horizontal-rule/horizontal-rule-spec.ts +1 -4
  213. package/src/horizontal-rule/horizontal-rule.ts +3 -12
  214. package/src/horizontal-rule/index.ts +3 -13
  215. package/src/image/image-commands/upload-image.spec.ts +245 -0
  216. package/src/image/image-commands/upload-image.ts +46 -11
  217. package/src/image/image-commands.ts +2 -8
  218. package/src/image/image-spec.ts +1 -4
  219. package/src/image/image-upload-handler.ts +2 -8
  220. package/src/image/image.ts +3 -12
  221. package/src/image/index.ts +3 -13
  222. package/src/input-rule/index.ts +2 -13
  223. package/src/italic/index.ts +3 -12
  224. package/src/italic/italic-commands.spec.ts +2 -10
  225. package/src/italic/italic-commands.ts +1 -5
  226. package/src/italic/italic-input-rule.spec.ts +1 -5
  227. package/src/italic/italic-input-rule.ts +1 -4
  228. package/src/italic/italic-keymap.ts +1 -5
  229. package/src/italic/italic-spec.ts +1 -4
  230. package/src/italic/italic.ts +3 -12
  231. package/src/link/index.spec.ts +10 -13
  232. package/src/link/index.ts +1 -5
  233. package/src/link/link-paste-rule.spec.ts +2 -9
  234. package/src/link/link-regex.spec.ts +1 -5
  235. package/src/list/index.ts +3 -12
  236. package/src/list/list-commands.ts +1 -5
  237. package/src/list/list-input-rules.ts +1 -4
  238. package/src/list/list-keymap.spec.ts +6 -10
  239. package/src/list/list-keymap.ts +2 -8
  240. package/src/list/list-plugins.ts +1 -4
  241. package/src/list/list-serializer.ts +2 -9
  242. package/src/list/list-spec.ts +3 -13
  243. package/src/list/list.spec.ts +10 -21
  244. package/src/list/list.ts +3 -12
  245. package/src/list/style.css +5 -5
  246. package/src/loro/index.ts +3 -13
  247. package/src/loro/loro-commands.ts +2 -8
  248. package/src/loro/loro-cursor-plugin.ts +21 -21
  249. package/src/loro/loro-keymap.ts +3 -11
  250. package/src/loro/loro-sync-plugin.ts +2 -8
  251. package/src/loro/loro-undo-plugin.ts +2 -8
  252. package/src/loro/loro.ts +16 -21
  253. package/src/mark-rule/apply.ts +3 -13
  254. package/src/mark-rule/mark-rule.spec.ts +2 -13
  255. package/src/mark-rule/mark-rule.ts +2 -13
  256. package/src/mark-rule/range.ts +2 -8
  257. package/src/mark-rule/types.ts +1 -4
  258. package/src/mention/index.ts +1 -8
  259. package/src/mod-click-prevention/index.ts +2 -9
  260. package/src/paragraph/paragraph-commands.ts +1 -5
  261. package/src/paragraph/paragraph-keymap.ts +2 -5
  262. package/src/paragraph/paragraph-spec.ts +1 -4
  263. package/src/paragraph/paragraph.ts +3 -14
  264. package/src/paste-rule/index.ts +2 -10
  265. package/src/paste-rule/mark-paste-rule.spec.ts +3 -13
  266. package/src/paste-rule/mark-paste-rule.ts +4 -14
  267. package/src/paste-rule/paste-rule-plugin.ts +2 -11
  268. package/src/paste-rule/paste-rule.spec.ts +4 -19
  269. package/src/paste-rule/split-text-by-regex.spec.ts +1 -5
  270. package/src/placeholder/index.ts +4 -16
  271. package/src/readonly/index.ts +2 -8
  272. package/src/search/index.ts +1 -6
  273. package/src/strike/index.ts +2 -2
  274. package/src/table/index.ts +10 -40
  275. package/src/table/table-commands/delete-cell-selection.spec.ts +1 -5
  276. package/src/table/table-commands/exit-table.spec.ts +1 -5
  277. package/src/table/table-commands/insert-table.spec.ts +1 -5
  278. package/src/table/table-commands/insert-table.ts +1 -4
  279. package/src/table/table-commands/move-table-column.spec.ts +1 -5
  280. package/src/table/table-commands/move-table-column.ts +1 -4
  281. package/src/table/table-commands/move-table-row.spec.ts +1 -5
  282. package/src/table/table-commands/move-table-row.ts +1 -4
  283. package/src/table/table-commands/select-table-cell.spec.ts +1 -5
  284. package/src/table/table-commands/select-table-column.spec.ts +1 -5
  285. package/src/table/table-commands/select-table-row.spec.ts +1 -5
  286. package/src/table/table-commands/select-table.spec.ts +1 -5
  287. package/src/table/table-commands/select-table.ts +1 -4
  288. package/src/table/table-commands.ts +8 -32
  289. package/src/table/table-plugins.ts +2 -8
  290. package/src/table/table-spec.spec.ts +2 -11
  291. package/src/table/table-spec.ts +2 -8
  292. package/src/table/table-utils.ts +2 -6
  293. package/src/table/table.ts +2 -8
  294. package/src/table/test-utils.ts +1 -4
  295. package/src/testing/clipboard.ts +1 -2
  296. package/src/testing/index.ts +9 -14
  297. package/src/testing/keyboard.ts +0 -30
  298. package/src/text/index.ts +1 -4
  299. package/src/text-align/index.ts +6 -6
  300. package/src/text-color/index.ts +3 -0
  301. package/src/text-color/text-color-commands.spec.ts +71 -0
  302. package/src/text-color/text-color-commands.ts +35 -0
  303. package/src/text-color/text-color-spec.spec.ts +297 -0
  304. package/src/text-color/text-color-spec.ts +58 -0
  305. package/src/text-color/text-color.ts +21 -0
  306. package/src/virtual-selection/index.ts +3 -14
  307. package/src/yjs/index.ts +5 -20
  308. package/src/yjs/yjs-commands.ts +2 -8
  309. package/src/yjs/yjs-cursor-plugin.ts +3 -5
  310. package/src/yjs/yjs-keymap.ts +3 -11
  311. package/src/yjs/yjs-sync-plugin.ts +1 -4
  312. package/src/yjs/yjs-types.ts +10 -0
  313. package/src/yjs/yjs-undo-plugin.ts +2 -8
  314. package/src/yjs/yjs.ts +6 -24
  315. package/dist/drop-indicator-B1QHFb5m.js.map +0 -1
  316. package/dist/enter-rule-CzWOZF_Z.js.map +0 -1
  317. package/dist/file-DrfcSid-.js.map +0 -1
  318. package/dist/index-oIc1a2f2.d.ts.map +0 -1
  319. package/dist/input-rule-dmsb3j6w.js.map +0 -1
  320. package/dist/mark-rule-BcLB4Uv2.js.map +0 -1
  321. package/dist/paste-rule-pVb4sqvJ.js.map +0 -1
  322. package/dist/shiki-highlighter-chunk-rkzofy4z.d.ts.map +0 -1
  323. package/dist/table-BRDh_9mG.js.map +0 -1
  324. package/src/testing/format-html.ts +0 -5
@@ -1 +1 @@
1
- {"version":3,"file":"prosekit-extensions-code-block.js","names":["existCodeBlock: Command","loaded: ((options: HighlighterOptions) => HighlighterResult) | undefined","createOrGetHighlighter","parser: Parser | undefined"],"sources":["../src/code-block/code-block-commands.ts","../src/code-block/code-block-input-rule.ts","../src/code-block/code-block-keymap.ts","../src/code-block/code-block-spec.ts","../src/code-block/code-block.ts","../src/code-block/code-block-highlight.ts","../src/code-block/shiki-highlighter.ts","../src/code-block/shiki-parser.ts","../src/code-block/code-block-shiki.ts"],"sourcesContent":["import {\n defineCommands,\n insertNode,\n setBlockType,\n setNodeAttrs,\n toggleNode,\n type Extension,\n} from '@prosekit/core'\n\nimport type { CodeBlockAttrs } from './code-block-types'\n\n/**\n * @internal\n */\nexport type CodeBlockCommandsExtension = Extension<{\n Commands: {\n setCodeBlock: [attrs?: CodeBlockAttrs]\n insertCodeBlock: [attrs?: CodeBlockAttrs]\n toggleCodeBlock: [attrs?: CodeBlockAttrs]\n setCodeBlockAttrs: [attrs: CodeBlockAttrs]\n }\n}>\n\n/**\n * Adds commands for working with `codeBlock` nodes.\n *\n * @public\n */\nexport function defineCodeBlockCommands(): CodeBlockCommandsExtension {\n return defineCommands({\n setCodeBlock: (attrs?: CodeBlockAttrs) => {\n return setBlockType({ type: 'codeBlock', attrs })\n },\n insertCodeBlock: (attrs?: CodeBlockAttrs) => {\n return insertNode({ type: 'codeBlock', attrs })\n },\n toggleCodeBlock: (attrs?: CodeBlockAttrs) => {\n return toggleNode({ type: 'codeBlock', attrs })\n },\n setCodeBlockAttrs: (attrs: CodeBlockAttrs) => {\n return setNodeAttrs({ type: 'codeBlock', attrs })\n },\n })\n}\n","import type { PlainExtension } from '@prosekit/core'\n\nimport { defineTextBlockEnterRule } from '../enter-rule'\nimport { defineTextBlockInputRule } from '../input-rule'\n\nimport type { CodeBlockAttrs } from './code-block-types'\n\n/**\n * Adds input rules for `codeBlock` nodes.\n *\n * @public\n */\nexport function defineCodeBlockInputRule(): PlainExtension {\n return defineTextBlockInputRule({\n regex: /^```(\\S*)\\s$/,\n type: 'codeBlock',\n attrs: getAttrs,\n })\n}\n\n/**\n * Adds enter rules for `codeBlock` nodes.\n *\n * @public\n */\nexport function defineCodeBlockEnterRule(): PlainExtension {\n return defineTextBlockEnterRule({\n regex: /^```(\\S*)$/,\n type: 'codeBlock',\n attrs: getAttrs,\n })\n}\n\nfunction getAttrs(match: RegExpMatchArray): CodeBlockAttrs {\n return { language: match[1] || '' }\n}\n","import {\n defaultBlockAt,\n defineKeymap,\n type PlainExtension,\n} from '@prosekit/core'\nimport {\n TextSelection,\n type Command,\n} from '@prosekit/pm/state'\n\n/**\n * Defines the keymap for code blocks.\n */\nexport function defineCodeBlockKeymap(): PlainExtension {\n return defineKeymap({\n Enter: existCodeBlock,\n })\n}\n\n/**\n * Exit a code block and insert a default block below if the cursor is at the\n * end of the code block and the code block is ended with two new lines.\n */\nconst existCodeBlock: Command = (state, dispatch) => {\n if (!state.selection.empty) {\n return false\n }\n\n const { $head } = state.selection\n const parent = $head.parent\n if (\n parent.isTextblock\n && parent.type.spec.code\n && $head.parentOffset === parent.content.size\n && parent.textContent.endsWith('\\n\\n')\n ) {\n const grandParent = $head.node(-1)\n const insertIndex = $head.indexAfter(-1)\n const type = defaultBlockAt(grandParent.contentMatchAt(insertIndex))\n\n if (!type || !grandParent.canReplaceWith(insertIndex, insertIndex, type)) {\n return false\n }\n\n if (dispatch) {\n const { tr } = state\n tr.delete($head.pos - 2, $head.pos)\n const pos = tr.selection.$head.after()\n const node = type.createAndFill()\n if (node) {\n tr.replaceWith(pos, pos, node)\n tr.setSelection(TextSelection.near(tr.doc.resolve(pos), 1))\n dispatch(tr.scrollIntoView())\n }\n }\n\n return true\n }\n\n return false\n}\n","import {\n defineNodeSpec,\n type Extension,\n} from '@prosekit/core'\n\nimport type { CodeBlockAttrs } from './code-block-types'\n\n/**\n * @internal\n */\nexport type CodeBlockSpecExtension = Extension<{\n Nodes: {\n codeBlock: CodeBlockAttrs\n }\n}>\n\n/**\n * Defines the `codeBlock` node spec.\n *\n * @public\n */\nexport function defineCodeBlockSpec(): CodeBlockSpecExtension {\n return defineNodeSpec({\n name: 'codeBlock',\n content: 'text*',\n group: 'block',\n code: true,\n defining: true,\n marks: '',\n attrs: { language: { default: '', validate: 'string' } },\n parseDOM: [\n {\n tag: 'pre',\n preserveWhitespace: 'full',\n getAttrs: (node): CodeBlockAttrs => {\n const language = extractLanguageFromElement(node)\n || extractLanguageFromElement(node.querySelector('code'))\n return { language }\n },\n },\n ],\n toDOM(node) {\n const { language } = node.attrs as CodeBlockAttrs\n return [\n 'pre',\n { 'data-language': language || undefined },\n // `class: language-${language}` is used by remark-rehype to highlight the code block\n ['code', { class: language ? `language-${language}` : undefined }, 0],\n ]\n },\n })\n}\n\nfunction extractLanguageFromElement(element: HTMLElement | null | undefined): string {\n if (!element) {\n return ''\n }\n\n const attr = element.getAttribute('data-language')\n if (attr) {\n return attr\n }\n\n const className = element.className\n const match = className.match(/language-(\\w+)/)\n if (match) {\n return match[1]\n }\n\n return ''\n}\n","import {\n union,\n type Union,\n} from '@prosekit/core'\n\nimport {\n defineCodeBlockCommands,\n type CodeBlockCommandsExtension,\n} from './code-block-commands'\nimport {\n defineCodeBlockEnterRule,\n defineCodeBlockInputRule,\n} from './code-block-input-rule'\nimport { defineCodeBlockKeymap } from './code-block-keymap'\nimport {\n defineCodeBlockSpec,\n type CodeBlockSpecExtension,\n} from './code-block-spec'\n\n/**\n * @internal\n */\nexport type CodeBlockExtension = Union<\n [CodeBlockSpecExtension, CodeBlockCommandsExtension]\n>\n\n/**\n * Adds `codeBlock` nodes to the editor. This includes the following extensions:\n *\n * - {@link defineCodeBlockSpec}\n * - {@link defineCodeBlockInputRule}\n * - {@link defineCodeBlockEnterRule}\n * - {@link defineCodeBlockKeymap}\n * - {@link defineCodeBlockCommands}.\n *\n * @public\n */\nexport function defineCodeBlock(): CodeBlockExtension {\n return union(\n defineCodeBlockSpec(),\n defineCodeBlockInputRule(),\n defineCodeBlockEnterRule(),\n defineCodeBlockKeymap(),\n defineCodeBlockCommands(),\n )\n}\n","import {\n definePlugin,\n type Extension,\n} from '@prosekit/core'\nimport {\n createHighlightPlugin,\n type Parser,\n} from 'prosemirror-highlight'\n\n/**\n * @public\n *\n * An alias for the `Parser` type from the `prosemirror-highlight` package.\n */\nexport type HighlightParser = Parser\n\n/**\n * @public\n */\nexport type CodeBlockHighlightOptions = {\n parser: HighlightParser\n}\n\n/**\n * Adds syntax highlighting to code blocks. This function requires a `Parser`\n * instance from the `prosemirror-highlight` package. See the\n * [documentation](https://github.com/ocavue/prosemirror-highlight) for more\n * information.\n *\n * @param options\n *\n * @public\n */\nexport function defineCodeBlockHighlight({\n parser,\n}: CodeBlockHighlightOptions): Extension {\n return definePlugin(\n createHighlightPlugin({ parser }),\n )\n}\n","import type {\n HighlighterOptions,\n HighlighterResult,\n} from './shiki-highlighter-chunk'\n\nlet loaded: ((options: HighlighterOptions) => HighlighterResult) | undefined\n\nasync function load() {\n const { createOrGetHighlighter } = await import('./shiki-highlighter-chunk')\n loaded = createOrGetHighlighter\n}\n\nexport function createOrGetHighlighter(\n options: HighlighterOptions,\n): HighlighterResult {\n if (!loaded) {\n return { promise: load() }\n }\n return loaded(options)\n}\n\nexport type { HighlighterOptions }\n","import type { Parser } from 'prosemirror-highlight'\nimport { createParser } from 'prosemirror-highlight/shiki'\n\nimport type { ShikiBundledLanguage } from './shiki-bundle'\nimport {\n createOrGetHighlighter,\n type HighlighterOptions,\n} from './shiki-highlighter'\n\n/**\n * @internal\n */\nexport function createLazyParser(\n highlighterOptions: HighlighterOptions,\n): Parser {\n let parser: Parser | undefined\n\n return function lazyParser(options) {\n const language = (options.language || '') as ShikiBundledLanguage\n const { highlighter, promise } = createOrGetHighlighter({\n ...highlighterOptions,\n langs: [language],\n })\n\n if (!highlighter) {\n return promise\n }\n\n if (!parser) {\n parser = createParser(highlighter, {\n theme: highlighterOptions.themes[0],\n })\n }\n return parser(options)\n }\n}\n","import type { Extension } from '@prosekit/core'\nimport type { SpecialLanguage } from 'shiki'\n\nimport { defineCodeBlockHighlight } from './code-block-highlight'\nimport type {\n ShikiBundledLanguage,\n ShikiBundledTheme,\n} from './shiki-bundle'\nimport type { ShikiHighlighterOptions } from './shiki-highlighter-chunk'\nimport { createLazyParser } from './shiki-parser'\n\n/**\n * The options to configure the Shiki highlighter.\n *\n * @public\n */\nexport interface CodeBlockShikiOptions extends Omit<ShikiHighlighterOptions, 'themes' | 'langs' | 'engine'> {\n /**\n * A list of Shiki themes to pre-load. The first theme in the list will be\n * used to render the code block.\n *\n * @default ['one-dark-pro']\n */\n themes?: ShikiBundledTheme[]\n\n /**\n * A list of Shiki languages to pre-load.\n *\n * @default ['text']\n */\n langs?: (ShikiBundledLanguage | SpecialLanguage)[]\n\n /**\n * The RegExp engine to use. By default, the JavaScript engine is used.\n */\n engine?: ShikiHighlighterOptions['engine']\n}\n\n/**\n * Adds syntax highlighting to code blocks using the [Shiki](https://github.com/shikijs/shiki) package.\n *\n * It will set two CSS variables on the code block elements:\n *\n * - `--prosemirror-highlight`: sets text color\n * - `--prosemirror-highlight-bg`: sets background color\n *\n * @param options - The options to configure the Shiki highlighter.\n *\n * @public\n */\nexport function defineCodeBlockShiki({\n themes = ['one-dark-pro'],\n langs = ['text'],\n ...rest\n}: CodeBlockShikiOptions = {}): Extension {\n const parser = createLazyParser({ themes, langs, ...rest })\n return defineCodeBlockHighlight({ parser })\n}\n"],"mappings":";;;;;;;;;;;;;;AA4BA,SAAgB,0BAAsD;AACpE,QAAO,eAAe;EACpB,eAAe,UAA2B;AACxC,UAAO,aAAa;IAAE,MAAM;IAAa;IAAO,CAAC;;EAEnD,kBAAkB,UAA2B;AAC3C,UAAO,WAAW;IAAE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,OAAO,QAAQ;;;;;;;;ACNxB,SAAgB,iBACd,oBACQ;CACR,IAAIC;AAEJ,QAAO,SAAS,WAAW,SAAS;EAClC,MAAM,WAAY,QAAQ,YAAY;EACtC,MAAM,EAAE,aAAa,YAAY,uBAAuB;GACtD,GAAG;GACH,OAAO,CAAC,SAAS;GAClB,CAAC;AAEF,MAAI,CAAC,YACH,QAAO;AAGT,MAAI,CAAC,OACH,UAAS,aAAa,aAAa,EACjC,OAAO,mBAAmB,OAAO,IAClC,CAAC;AAEJ,SAAO,OAAO,QAAQ;;;;;;;;;;;;;;;;;;ACiB1B,SAAgB,qBAAqB,EACnC,SAAS,CAAC,eAAe,EACzB,QAAQ,CAAC,OAAO,EAChB,GAAG,SACsB,EAAE,EAAa;AAExC,QAAO,yBAAyB,EAAE,QADnB,iBAAiB;EAAE;EAAQ;EAAO,GAAG;EAAM,CAAC,EACjB,CAAC"}
1
+ {"version":3,"file":"prosekit-extensions-code-block.js","names":[],"sources":["../src/code-block/code-block-commands.ts","../src/code-block/code-block-input-rule.ts","../src/code-block/code-block-keymap.ts","../src/code-block/code-block-spec.ts","../src/code-block/code-block.ts","../src/code-block/code-block-highlight.ts","../src/code-block/shiki-highlighter.ts","../src/code-block/shiki-parser.ts","../src/code-block/code-block-shiki.ts"],"sourcesContent":["import { defineCommands, insertNode, setBlockType, setNodeAttrs, toggleNode, type Extension } from '@prosekit/core'\n\nimport type { CodeBlockAttrs } from './code-block-types'\n\n/**\n * @internal\n */\nexport type CodeBlockCommandsExtension = Extension<{\n Commands: {\n setCodeBlock: [attrs?: CodeBlockAttrs]\n insertCodeBlock: [attrs?: CodeBlockAttrs]\n toggleCodeBlock: [attrs?: CodeBlockAttrs]\n setCodeBlockAttrs: [attrs: CodeBlockAttrs]\n }\n}>\n\n/**\n * Adds commands for working with `codeBlock` nodes.\n *\n * @public\n */\nexport function defineCodeBlockCommands(): CodeBlockCommandsExtension {\n return defineCommands({\n setCodeBlock: (attrs?: CodeBlockAttrs) => {\n return setBlockType({ type: 'codeBlock', attrs })\n },\n insertCodeBlock: (attrs?: CodeBlockAttrs) => {\n return insertNode({ type: 'codeBlock', attrs })\n },\n toggleCodeBlock: (attrs?: CodeBlockAttrs) => {\n return toggleNode({ type: 'codeBlock', attrs })\n },\n setCodeBlockAttrs: (attrs: CodeBlockAttrs) => {\n return setNodeAttrs({ type: 'codeBlock', attrs })\n },\n })\n}\n","import type { PlainExtension } from '@prosekit/core'\n\nimport { defineTextBlockEnterRule } from '../enter-rule'\nimport { defineTextBlockInputRule } from '../input-rule'\n\nimport type { CodeBlockAttrs } from './code-block-types'\n\n/**\n * Adds input rules for `codeBlock` nodes.\n *\n * @public\n */\nexport function defineCodeBlockInputRule(): PlainExtension {\n return defineTextBlockInputRule({\n regex: /^```(\\S*)\\s$/,\n type: 'codeBlock',\n attrs: getAttrs,\n })\n}\n\n/**\n * Adds enter rules for `codeBlock` nodes.\n *\n * @public\n */\nexport function defineCodeBlockEnterRule(): PlainExtension {\n return defineTextBlockEnterRule({\n regex: /^```(\\S*)$/,\n type: 'codeBlock',\n attrs: getAttrs,\n })\n}\n\nfunction getAttrs(match: RegExpMatchArray): CodeBlockAttrs {\n return { language: match[1] || '' }\n}\n","import { defaultBlockAt, defineKeymap, type PlainExtension } from '@prosekit/core'\nimport { TextSelection, type Command } from '@prosekit/pm/state'\n\n/**\n * Defines the keymap for code blocks.\n */\nexport function defineCodeBlockKeymap(): PlainExtension {\n return defineKeymap({\n Enter: existCodeBlock,\n })\n}\n\n/**\n * Exit a code block and insert a default block below if the cursor is at the\n * end of the code block and the code block is ended with two new lines.\n */\nconst existCodeBlock: Command = (state, dispatch) => {\n if (!state.selection.empty) {\n return false\n }\n\n const { $head } = state.selection\n const parent = $head.parent\n if (\n parent.isTextblock\n && parent.type.spec.code\n && $head.parentOffset === parent.content.size\n && parent.textContent.endsWith('\\n\\n')\n ) {\n const grandParent = $head.node(-1)\n const insertIndex = $head.indexAfter(-1)\n const type = defaultBlockAt(grandParent.contentMatchAt(insertIndex))\n\n if (!type || !grandParent.canReplaceWith(insertIndex, insertIndex, type)) {\n return false\n }\n\n if (dispatch) {\n const { tr } = state\n tr.delete($head.pos - 2, $head.pos)\n const pos = tr.selection.$head.after()\n const node = type.createAndFill()\n if (node) {\n tr.replaceWith(pos, pos, node)\n tr.setSelection(TextSelection.near(tr.doc.resolve(pos), 1))\n dispatch(tr.scrollIntoView())\n }\n }\n\n return true\n }\n\n return false\n}\n","import { defineNodeSpec, type Extension } from '@prosekit/core'\n\nimport type { CodeBlockAttrs } from './code-block-types'\n\n/**\n * @internal\n */\nexport type CodeBlockSpecExtension = Extension<{\n Nodes: {\n codeBlock: CodeBlockAttrs\n }\n}>\n\n/**\n * Defines the `codeBlock` node spec.\n *\n * @public\n */\nexport function defineCodeBlockSpec(): CodeBlockSpecExtension {\n return defineNodeSpec({\n name: 'codeBlock',\n content: 'text*',\n group: 'block',\n code: true,\n defining: true,\n marks: '',\n attrs: { language: { default: '', validate: 'string' } },\n parseDOM: [\n {\n tag: 'pre',\n preserveWhitespace: 'full',\n getAttrs: (node): CodeBlockAttrs => {\n const language = extractLanguageFromElement(node)\n || extractLanguageFromElement(node.querySelector('code'))\n return { language }\n },\n },\n ],\n toDOM(node) {\n const { language } = node.attrs as CodeBlockAttrs\n return [\n 'pre',\n { 'data-language': language || undefined },\n // `class: language-${language}` is used by remark-rehype to highlight the code block\n ['code', { class: language ? `language-${language}` : undefined }, 0],\n ]\n },\n })\n}\n\nfunction extractLanguageFromElement(element: HTMLElement | null | undefined): string {\n if (!element) {\n return ''\n }\n\n const attr = element.getAttribute('data-language')\n if (attr) {\n return attr\n }\n\n const className = element.className\n const match = className.match(/language-(\\w+)/)\n if (match) {\n return match[1]\n }\n\n return ''\n}\n","import { union, type Union } from '@prosekit/core'\n\nimport { defineCodeBlockCommands, type CodeBlockCommandsExtension } from './code-block-commands'\nimport { defineCodeBlockEnterRule, defineCodeBlockInputRule } from './code-block-input-rule'\nimport { defineCodeBlockKeymap } from './code-block-keymap'\nimport { defineCodeBlockSpec, type CodeBlockSpecExtension } from './code-block-spec'\n\n/**\n * @internal\n */\nexport type CodeBlockExtension = Union<\n [CodeBlockSpecExtension, CodeBlockCommandsExtension]\n>\n\n/**\n * Adds `codeBlock` nodes to the editor. This includes the following extensions:\n *\n * - {@link defineCodeBlockSpec}\n * - {@link defineCodeBlockInputRule}\n * - {@link defineCodeBlockEnterRule}\n * - {@link defineCodeBlockKeymap}\n * - {@link defineCodeBlockCommands}.\n *\n * @public\n */\nexport function defineCodeBlock(): CodeBlockExtension {\n return union(\n defineCodeBlockSpec(),\n defineCodeBlockInputRule(),\n defineCodeBlockEnterRule(),\n defineCodeBlockKeymap(),\n defineCodeBlockCommands(),\n )\n}\n","import { definePlugin, type Extension } from '@prosekit/core'\nimport { createHighlightPlugin, type Parser } from 'prosemirror-highlight'\n\n/**\n * @public\n *\n * An alias for the `Parser` type from the `prosemirror-highlight` package.\n */\nexport type HighlightParser = Parser\n\n/**\n * @public\n */\nexport type CodeBlockHighlightOptions = {\n parser: HighlightParser\n}\n\n/**\n * Adds syntax highlighting to code blocks. This function requires a `Parser`\n * instance from the `prosemirror-highlight` package. See the\n * [documentation](https://github.com/ocavue/prosemirror-highlight) for more\n * information.\n *\n * @param options\n *\n * @public\n */\nexport function defineCodeBlockHighlight({\n parser,\n}: CodeBlockHighlightOptions): Extension {\n return definePlugin(\n createHighlightPlugin({ parser }),\n )\n}\n","import type { HighlighterOptions, HighlighterResult } from './shiki-highlighter-chunk'\n\nlet loaded: ((options: HighlighterOptions) => HighlighterResult) | undefined\n\nasync function load() {\n const { createOrGetHighlighter } = await import('./shiki-highlighter-chunk')\n loaded = createOrGetHighlighter\n}\n\nexport function createOrGetHighlighter(\n options: HighlighterOptions,\n): HighlighterResult {\n if (!loaded) {\n return { promise: load() }\n }\n return loaded(options)\n}\n\nexport type { HighlighterOptions }\n","import type { Parser } from 'prosemirror-highlight'\nimport { createParser } from 'prosemirror-highlight/shiki'\n\nimport type { ShikiBundledLanguage } from './shiki-bundle'\nimport { createOrGetHighlighter, type HighlighterOptions } from './shiki-highlighter'\n\n/**\n * @internal\n */\nexport function createLazyParser(\n highlighterOptions: HighlighterOptions,\n): Parser {\n let parser: Parser | undefined\n\n return function lazyParser(options) {\n const language = (options.language || '') as ShikiBundledLanguage\n const { highlighter, promise } = createOrGetHighlighter({\n ...highlighterOptions,\n langs: [language],\n })\n\n if (!highlighter) {\n return promise\n }\n\n if (!parser) {\n parser = createParser(highlighter, {\n theme: highlighterOptions.themes[0],\n })\n }\n return parser(options)\n }\n}\n","import type { Extension } from '@prosekit/core'\nimport type { SpecialLanguage } from 'shiki'\n\nimport { defineCodeBlockHighlight } from './code-block-highlight'\nimport type { ShikiBundledLanguage, ShikiBundledTheme } from './shiki-bundle'\nimport type { ShikiHighlighterOptions } from './shiki-highlighter-chunk'\nimport { createLazyParser } from './shiki-parser'\n\n/**\n * The options to configure the Shiki highlighter.\n *\n * @public\n */\nexport interface CodeBlockShikiOptions extends Omit<ShikiHighlighterOptions, 'themes' | 'langs' | 'engine'> {\n /**\n * A list of Shiki themes to pre-load. The first theme in the list will be\n * used to render the code block.\n *\n * @default ['one-dark-pro']\n */\n themes?: ShikiBundledTheme[]\n\n /**\n * A list of Shiki languages to pre-load.\n *\n * @default ['text']\n */\n langs?: (ShikiBundledLanguage | SpecialLanguage)[]\n\n /**\n * The RegExp engine to use. By default, the JavaScript engine is used.\n */\n engine?: ShikiHighlighterOptions['engine']\n}\n\n/**\n * Adds syntax highlighting to code blocks using the [Shiki](https://github.com/shikijs/shiki) package.\n *\n * It will set two CSS variables on the code block elements:\n *\n * - `--prosemirror-highlight`: sets text color\n * - `--prosemirror-highlight-bg`: sets background color\n *\n * @param options - The options to configure the Shiki highlighter.\n *\n * @public\n */\nexport function defineCodeBlockShiki({\n themes = ['one-dark-pro'],\n langs = ['text'],\n ...rest\n}: CodeBlockShikiOptions = {}): Extension {\n const parser = createLazyParser({ themes, langs, ...rest })\n return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,EAAE,QAAQ,CAAC,CAClC;;;;;AC9BH,IAAI;AAEJ,eAAe,OAAO;CACpB,MAAM,EAAE,2BAA2B,MAAM,OAAO;AAChD,UAAS;;AAGX,SAAgB,uBACd,SACmB;AACnB,KAAI,CAAC,OACH,QAAO,EAAE,SAAS,MAAM,EAAE;AAE5B,QAAO,OAAO,QAAQ;;;;;;;;ACNxB,SAAgB,iBACd,oBACQ;CACR,IAAI;AAEJ,QAAO,SAAS,WAAW,SAAS;EAClC,MAAM,WAAY,QAAQ,YAAY;EACtC,MAAM,EAAE,aAAa,YAAY,uBAAuB;GACtD,GAAG;GACH,OAAO,CAAC,SAAS;GAClB,CAAC;AAEF,MAAI,CAAC,YACH,QAAO;AAGT,MAAI,CAAC,OACH,UAAS,aAAa,aAAa,EACjC,OAAO,mBAAmB,OAAO,IAClC,CAAC;AAEJ,SAAO,OAAO,QAAQ;;;;;;;;;;;;;;;;;;ACiB1B,SAAgB,qBAAqB,EACnC,SAAS,CAAC,eAAe,EACzB,QAAQ,CAAC,OAAO,EAChB,GAAG,SACsB,EAAE,EAAa;AAExC,QAAO,yBAAyB,EAAE,QADnB,iBAAiB;EAAE;EAAQ;EAAO,GAAG;EAAM,CAAC,EACjB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"prosekit-extensions-code.d.ts","names":[],"sources":["../src/code/code-commands.ts","../src/code/code-spec.ts","../src/code/code.ts","../src/code/code-input-rule.ts","../src/code/code-keymap.ts"],"sourcesContent":[],"mappings":";;;;;;;AASY,KAAA,qBAAA,GAAwB,SAAA,CAAA;EASpB,QAAA,EAAA;;;;ACThB;AASA;;iBDAgB,kBAAA,CAAA,GAAsB;;;;;AATtC;AASgB,KCTJ,iBAAA,GAAoB,SDSM,CAAA;;UCP5B;;AAFV,CAAA,CAAA;AASA;;;iBAAgB,cAAA,CAAA,GAAkB;;;;ADTlC;AASA;KECY,aAAA,GAAgB,OAAO,mBAAmB;;;ADVtD;AASgB,iBCMA,UAAA,CAAA,CDNkB,ECMJ,aDNqB;;;;;;ADTvC,iBGCI,mBAAA,CAAA,CHDoB,EGCG,cHDM;;;;;;AAAjC,iBIAI,gBAAA,CAAA,CJAoB,EIAA,cJAS"}
1
+ {"version":3,"file":"prosekit-extensions-code.d.ts","names":[],"sources":["../src/code/code-commands.ts","../src/code/code-spec.ts","../src/code/code.ts","../src/code/code-input-rule.ts","../src/code/code-keymap.ts"],"mappings":";;;;;;;KAKY,qBAAA,GAAwB,SAAA;EAClC,QAAA;IACE,UAAA;EAAA;AAAA;;;;iBAOY,kBAAA,CAAA,GAAsB,qBAAA;;;;;AATtC;KCCY,iBAAA,GAAoB,SAAA;EAC9B,KAAA;IACE,IAAA,EAAM,KAAA;EAAA;AAAA;;;;iBAOM,cAAA,CAAA,GAAkB,iBAAA;;;;ADVlC;;KEKY,aAAA,GAAgB,KAAA,EAAO,iBAAA,EAAmB,qBAAA;;;;iBAKtC,UAAA,CAAA,GAAc,aAAA;;;;;;iBCRd,mBAAA,CAAA,GAAuB,cAAA;;;;;;iBCFvB,gBAAA,CAAA,GAAoB,cAAA"}
@@ -1,4 +1,4 @@
1
- import { r as defineMarkInputRule } from "./input-rule-dmsb3j6w.js";
1
+ import { r as defineMarkInputRule } from "./input-rule-COGr_GBb.js";
2
2
  import { canUseRegexLookbehind, defineCommands, defineKeymap, defineMarkSpec, toggleMark, union } from "@prosekit/core";
3
3
 
4
4
  //#region src/code/code-commands.ts
@@ -1 +1 @@
1
- {"version":3,"file":"prosekit-extensions-code.js","names":[],"sources":["../src/code/code-commands.ts","../src/code/code-input-rule.ts","../src/code/code-keymap.ts","../src/code/code-spec.ts","../src/code/code.ts"],"sourcesContent":["import {\n defineCommands,\n toggleMark,\n type Extension,\n} from '@prosekit/core'\n\n/**\n * @internal\n */\nexport type CodeCommandsExtension = Extension<{\n Commands: {\n toggleCode: []\n }\n}>\n\n/**\n * @internal\n */\nexport function defineCodeCommands(): CodeCommandsExtension {\n return defineCommands({\n toggleCode: () => toggleMark({ type: 'code' }),\n })\n}\n","import {\n canUseRegexLookbehind,\n type PlainExtension,\n} from '@prosekit/core'\n\nimport { defineMarkInputRule } from '../input-rule'\n\n/**\n * @internal\n */\nexport function defineCodeInputRule(): PlainExtension {\n return defineMarkInputRule({\n regex: canUseRegexLookbehind()\n ? /(?<=\\s|^)`([^\\s`]|[^\\s`][^`]*[^\\s`])`$/\n : /`([^\\s`]|[^\\s`][^`]*[^\\s`])`$/,\n type: 'code',\n })\n}\n","import {\n defineKeymap,\n toggleMark,\n type PlainExtension,\n} from '@prosekit/core'\n\n/**\n * @internal\n */\nexport function defineCodeKeymap(): PlainExtension {\n return defineKeymap({\n 'Mod-e': toggleMark({ type: 'code' }),\n })\n}\n","import {\n defineMarkSpec,\n type Extension,\n} from '@prosekit/core'\nimport type { Attrs } from '@prosekit/pm/model'\n\n/**\n * @internal\n */\nexport type CodeSpecExtension = Extension<{\n Marks: {\n code: Attrs\n }\n}>\n\n/**\n * @internal\n */\nexport function defineCodeSpec(): CodeSpecExtension {\n return defineMarkSpec({\n name: 'code',\n parseDOM: [{ tag: 'code' }],\n code: true,\n toDOM() {\n return ['code', 0]\n },\n })\n}\n","import {\n union,\n type Union,\n} from '@prosekit/core'\n\nimport {\n defineCodeCommands,\n type CodeCommandsExtension,\n} from './code-commands'\nimport { defineCodeInputRule } from './code-input-rule'\nimport { defineCodeKeymap } from './code-keymap'\nimport {\n defineCodeSpec,\n type CodeSpecExtension,\n} from './code-spec'\n\n/**\n * @internal\n */\nexport type CodeExtension = Union<[CodeSpecExtension, CodeCommandsExtension]>\n\n/**\n * @public\n */\nexport function defineCode(): CodeExtension {\n return union(\n defineCodeSpec(),\n defineCodeCommands(),\n defineCodeKeymap(),\n defineCodeInputRule(),\n )\n}\n"],"mappings":";;;;;;;AAkBA,SAAgB,qBAA4C;AAC1D,QAAO,eAAe,EACpB,kBAAkB,WAAW,EAAE,MAAM,QAAQ,CAAC,EAC/C,CAAC;;;;;;;;ACXJ,SAAgB,sBAAsC;AACpD,QAAO,oBAAoB;EACzB,OAAO,uBAAuB,GAC1B,2CACA;EACJ,MAAM;EACP,CAAC;;;;;;;;ACPJ,SAAgB,mBAAmC;AACjD,QAAO,aAAa,EAClB,SAAS,WAAW,EAAE,MAAM,QAAQ,CAAC,EACtC,CAAC;;;;;;;;ACMJ,SAAgB,iBAAoC;AAClD,QAAO,eAAe;EACpB,MAAM;EACN,UAAU,CAAC,EAAE,KAAK,QAAQ,CAAC;EAC3B,MAAM;EACN,QAAQ;AACN,UAAO,CAAC,QAAQ,EAAE;;EAErB,CAAC;;;;;;;;ACFJ,SAAgB,aAA4B;AAC1C,QAAO,MACL,gBAAgB,EAChB,oBAAoB,EACpB,kBAAkB,EAClB,qBAAqB,CACtB"}
1
+ {"version":3,"file":"prosekit-extensions-code.js","names":[],"sources":["../src/code/code-commands.ts","../src/code/code-input-rule.ts","../src/code/code-keymap.ts","../src/code/code-spec.ts","../src/code/code.ts"],"sourcesContent":["import { defineCommands, toggleMark, type Extension } from '@prosekit/core'\n\n/**\n * @internal\n */\nexport type CodeCommandsExtension = Extension<{\n Commands: {\n toggleCode: []\n }\n}>\n\n/**\n * @internal\n */\nexport function defineCodeCommands(): CodeCommandsExtension {\n return defineCommands({\n toggleCode: () => toggleMark({ type: 'code' }),\n })\n}\n","import { canUseRegexLookbehind, type PlainExtension } from '@prosekit/core'\n\nimport { defineMarkInputRule } from '../input-rule'\n\n/**\n * @internal\n */\nexport function defineCodeInputRule(): PlainExtension {\n return defineMarkInputRule({\n regex: canUseRegexLookbehind()\n ? /(?<=\\s|^)`([^\\s`]|[^\\s`][^`]*[^\\s`])`$/\n : /`([^\\s`]|[^\\s`][^`]*[^\\s`])`$/,\n type: 'code',\n })\n}\n","import { defineKeymap, toggleMark, type PlainExtension } from '@prosekit/core'\n\n/**\n * @internal\n */\nexport function defineCodeKeymap(): PlainExtension {\n return defineKeymap({\n 'Mod-e': toggleMark({ type: 'code' }),\n })\n}\n","import { defineMarkSpec, type Extension } from '@prosekit/core'\nimport type { Attrs } from '@prosekit/pm/model'\n\n/**\n * @internal\n */\nexport type CodeSpecExtension = Extension<{\n Marks: {\n code: Attrs\n }\n}>\n\n/**\n * @internal\n */\nexport function defineCodeSpec(): CodeSpecExtension {\n return defineMarkSpec({\n name: 'code',\n parseDOM: [{ tag: 'code' }],\n code: true,\n toDOM() {\n return ['code', 0]\n },\n })\n}\n","import { union, type Union } from '@prosekit/core'\n\nimport { defineCodeCommands, type CodeCommandsExtension } from './code-commands'\nimport { defineCodeInputRule } from './code-input-rule'\nimport { defineCodeKeymap } from './code-keymap'\nimport { defineCodeSpec, type CodeSpecExtension } from './code-spec'\n\n/**\n * @internal\n */\nexport type CodeExtension = Union<[CodeSpecExtension, CodeCommandsExtension]>\n\n/**\n * @public\n */\nexport function defineCode(): CodeExtension {\n return union(\n defineCodeSpec(),\n defineCodeCommands(),\n defineCodeKeymap(),\n defineCodeInputRule(),\n )\n}\n"],"mappings":";;;;;;;AAcA,SAAgB,qBAA4C;AAC1D,QAAO,eAAe,EACpB,kBAAkB,WAAW,EAAE,MAAM,QAAQ,CAAC,EAC/C,CAAC;;;;;;;;ACVJ,SAAgB,sBAAsC;AACpD,QAAO,oBAAoB;EACzB,OAAO,uBAAuB,GAC1B,2CACA;EACJ,MAAM;EACP,CAAC;;;;;;;;ACRJ,SAAgB,mBAAmC;AACjD,QAAO,aAAa,EAClB,SAAS,WAAW,EAAE,MAAM,QAAQ,CAAC,EACtC,CAAC;;;;;;;;ACOJ,SAAgB,iBAAoC;AAClD,QAAO,eAAe;EACpB,MAAM;EACN,UAAU,CAAC,EAAE,KAAK,QAAQ,CAAC;EAC3B,MAAM;EACN,QAAQ;AACN,UAAO,CAAC,QAAQ,EAAE;;EAErB,CAAC;;;;;;;;ACRJ,SAAgB,aAA4B;AAC1C,QAAO,MACL,gBAAgB,EAChB,oBAAoB,EACpB,kBAAkB,EAClB,qBAAqB,CACtB"}
@@ -3,7 +3,6 @@ import { Transaction } from "@prosekit/pm/state";
3
3
  import { ProseMirrorNode } from "@prosekit/pm/model";
4
4
 
5
5
  //#region src/commit/index.d.ts
6
-
7
6
  /**
8
7
  * A JSON representation of a commit.
9
8
  */
@@ -1 +1 @@
1
- {"version":3,"file":"prosekit-extensions-commit.d.ts","names":[],"sources":["../src/commit/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;AAmB2B;UAejB,MAAA,CAIH;EAIG;;;EAgND,GAAA,EApNF,QAoNE;EAOH;;;EAwCM,MAAA,EA/PF,QA+PE;EAAW;AAAA;;;SA1Pd;;;;;iBA2MA,kBAAA,SAA2B,SAAS;cAOvC,cAAA;;;;;;;;YASM;;;;YAsBA;;;;YASA;;;;;iBASH,oBAAA,iBAAqC,iBAAiB"}
1
+ {"version":3,"file":"prosekit-extensions-commit.d.ts","names":[],"sources":["../src/commit/index.ts"],"mappings":";;;;;;;AAEmF;UAQzE,MAAA;;;;EAIR,GAAA,EAAK,QAAA;EASU;;;EALf,MAAA,EAAQ,QAAA;EAAR;;;;EAKA,KAAA,EAAO,QAAA;AAAA;AAAQ;;;AAAA,iBA2MR,kBAAA,CAAmB,MAAA,EAAQ,MAAA,GAAS,cAAA;AAAA,cAOvC,cAAA;EAAA,QACI,MAAA;EAAA,QACA,GAAA;EAAA,QACA,KAAA;EAViD;AAAA;;;EAgBzD,MAAA,CAAA,GAAU,MAAA;EAsBA;;;EAAV,IAAA,CAAK,GAAA,EAAK,eAAA;EA9BF;;;EAuCR,KAAA,CAAM,EAAA,EAAI,WAAA;AAAA;;;;iBASH,oBAAA,CAAqB,cAAA,EAAgB,cAAA,GAAiB,cAAA"}
@@ -99,7 +99,7 @@ function defineCommitDecoration(commit) {
99
99
  * Define an extension to display the changes from the given commit in the editor.
100
100
  */
101
101
  function defineCommitViewer(commit) {
102
- return union(defineDefaultState({ defaultDoc: commit.doc }), defineCommitDecoration(commit));
102
+ return union(defineDefaultState({ defaultContent: commit.doc }), defineCommitDecoration(commit));
103
103
  }
104
104
  var CommitRecorder = class {
105
105
  constructor() {
@@ -1 +1 @@
1
- {"version":3,"file":"prosekit-extensions-commit.js","names":["decorations: Decoration[]","commit: Commit"],"sources":["../src/commit/index.ts"],"sourcesContent":["import {\n defineDefaultState,\n definePlugin,\n jsonFromNode,\n union,\n type NodeJSON,\n type PlainExtension,\n type StepJSON,\n} from '@prosekit/core'\nimport {\n DOMSerializer,\n Fragment,\n Slice,\n type ProseMirrorNode,\n} from '@prosekit/pm/model'\nimport {\n PluginKey,\n ProseMirrorPlugin,\n type Transaction,\n} from '@prosekit/pm/state'\nimport { Step } from '@prosekit/pm/transform'\nimport {\n Decoration,\n DecorationSet,\n type EditorView,\n} from '@prosekit/pm/view'\nimport {\n ChangeSet,\n type Change,\n} from 'prosemirror-changeset'\n\n/**\n * A JSON representation of a commit.\n */\ninterface Commit {\n /**\n * The current doc node in the JSON format\n */\n doc: NodeJSON\n /**\n * The parent node in the JSON format\n */\n parent: NodeJSON\n /**\n * An array of steps in the JSON format that transform the parent node to the\n * current doc node.\n */\n steps: StepJSON[]\n}\n\nfunction getChanges(\n doc: ProseMirrorNode,\n parent: ProseMirrorNode,\n steps: Step[],\n): readonly Change[] {\n const initSet = ChangeSet.create(parent)\n const currSet = initSet.addSteps(\n doc,\n steps.map((step) => step.getMap()),\n null,\n )\n return currSet.changes\n}\n\nfunction renderDivWeight(view: EditorView): HTMLElement {\n const document = view.dom.ownerDocument\n return document.createElement('div')\n}\n\nfunction decorateDeletionSlice(\n slice: Slice,\n): Array<(view: EditorView) => HTMLElement> {\n // Get the fragment of the deleted content\n let { openStart, openEnd, content } = slice\n\n while (openStart > 0 && openEnd > 0 && content.childCount === 1) {\n openStart--\n openEnd--\n content = content.child(0).content\n }\n\n // Nothing to render\n if (content.childCount === 0) {\n return []\n }\n\n // For example, if the slice is\n // {\n // openStart: 1,\n // openEnd: 1,\n // content: <p>Hello</p><p>World</p>\n // }\n // We should render the following decorations:\n // <span>Hello</span>\n // <div></div>\n // <span>World</span>\n if (openStart > 0 && openEnd > 0 && content.childCount === 2) {\n const head = Fragment.from([content.child(0)])\n const tail = Fragment.from([content.child(1)])\n return [\n ...decorateDeletionSlice(new Slice(head, openStart, openStart)),\n renderDivWeight,\n ...decorateDeletionSlice(new Slice(tail, openEnd, openEnd)),\n ]\n }\n\n // For example, if the slice is\n // {\n // openStart: 1,\n // openEnd: 0,\n // content: <p>Hello</p><p>World</p>\n // }\n // We should render the following decorations:\n // <span>Hello</span>\n // <div><p>World</p></div>\n if (openStart > 0 && content.childCount >= 2) {\n const nodes = content.content\n const head = Fragment.from(nodes.slice(0, 1))\n const body = Fragment.from(nodes.slice(1))\n\n return [\n ...decorateDeletionSlice(new Slice(head, openStart, openStart)),\n ...decorateDeletionSlice(new Slice(body, 0, openEnd)),\n ]\n }\n\n // For example, if the slice is\n // {\n // openStart: 0,\n // openEnd: 1,\n // content: <p>Hello</p><p>World</p>\n // }\n // We should render the following decorations:\n // <div><p>Hello</p></div>\n // <span>World</span>\n if (openEnd > 0 && content.childCount >= 2) {\n const nodes = content.content\n const body = Fragment.from(nodes.slice(0, -1))\n const tail = Fragment.from(nodes.slice(-1))\n return [\n ...decorateDeletionSlice(new Slice(body, openStart, 0)),\n ...decorateDeletionSlice(new Slice(tail, openEnd, openEnd)),\n ]\n }\n\n const schema = content.child(0).type.schema\n const isInline = content.child(0).isInline\n\n const render = (view: EditorView): HTMLElement => {\n const document = view.dom.ownerDocument\n\n // Render the fragment to HTML\n const element = document.createElement(isInline ? 'span' : 'div')\n const serializer = DOMSerializer.fromSchema(schema)\n serializer.serializeFragment(content, { document }, element)\n\n // Add the class to the element\n element.classList.add('prosekit-commit-deletion')\n return element\n }\n\n return [render]\n}\n\nfunction decorateDeletion(\n /** The doc node before the deletion */\n doc: ProseMirrorNode,\n /** The start position of the deleted text in the doc node */\n from: number,\n /** The end position of the deleted text in the doc node */\n to: number,\n /** The insert position of the decoration in the doc node after the change */\n pos: number,\n): Decoration[] {\n const slice = doc.slice(from, to)\n\n const renders = decorateDeletionSlice(slice)\n const count = renders.length\n\n return renders.map((render, index) =>\n Decoration.widget(pos, render, {\n side: -20 - count + index,\n // Ensure the text in the decoration is able to be selected.\n ignoreSelection: true,\n })\n )\n}\n\nfunction decorateAddition(\n /** The start position of the inserted text in the doc node */\n from: number,\n /** The end position of the inserted text in the doc node */\n to: number,\n): Decoration {\n return Decoration.inline(from, to, { class: 'prosekit-commit-addition' })\n}\n\nfunction decorateChange(prev: ProseMirrorNode, change: Change): Decoration[] {\n const { fromA, toA, fromB, toB } = change\n const decorations: Decoration[] = []\n\n if (fromA < toA) {\n decorations.push(...decorateDeletion(prev, fromA, toA, fromB))\n }\n if (fromB < toB) {\n decorations.push(decorateAddition(fromB, toB))\n }\n\n return decorations\n}\n\nfunction decorateCommit(\n doc: ProseMirrorNode,\n parent: ProseMirrorNode,\n steps: Step[],\n): DecorationSet {\n const changes = getChanges(doc, parent, steps)\n const decorations = changes.flatMap((change) => decorateChange(parent, change))\n return DecorationSet.create(doc, decorations)\n}\n\nfunction defineCommitDecoration(commit: Commit): PlainExtension {\n const key = new PluginKey<DecorationSet>('prosekit-commit-decoration')\n\n return definePlugin(({ schema }): ProseMirrorPlugin => {\n const parent = schema.nodeFromJSON(commit.parent)\n const steps = commit.steps.map((step) => Step.fromJSON(schema, step))\n\n return new ProseMirrorPlugin({\n key,\n state: {\n init: (_, instance): DecorationSet => {\n return decorateCommit(instance.doc, parent, steps)\n },\n apply: (tr, deco: DecorationSet): DecorationSet => {\n return deco.map(tr.mapping, tr.doc)\n },\n },\n props: {\n decorations: (state): DecorationSet | undefined => {\n return key.getState(state)\n },\n },\n })\n })\n}\n\n/**\n * Define an extension to display the changes from the given commit in the editor.\n */\nfunction defineCommitViewer(commit: Commit): PlainExtension {\n return union(\n defineDefaultState({ defaultDoc: commit.doc }),\n defineCommitDecoration(commit),\n )\n}\n\nclass CommitRecorder {\n private parent: ProseMirrorNode | null = null\n private doc: ProseMirrorNode | null = null\n private steps: Step[] = []\n\n /**\n * Return a commit object including all changes since the last commit. `null`\n * will be returned if there is no change.\n */\n commit(): Commit | null {\n if (\n !this.parent\n || !this.doc\n || this.steps.length === 0\n || this.parent.eq(this.doc)\n ) {\n return null\n }\n\n const commit: Commit = {\n doc: jsonFromNode(this.doc),\n parent: jsonFromNode(this.parent),\n steps: this.steps.map((step) => step.toJSON() as StepJSON),\n }\n this.init(this.doc)\n return commit\n }\n\n /**\n * @internal\n */\n init(doc: ProseMirrorNode): void {\n this.doc = doc\n this.parent = doc\n this.steps = []\n }\n\n /**\n * @internal\n */\n apply(tr: Transaction): void {\n this.steps.push(...tr.steps)\n this.doc = tr.doc\n }\n}\n\n/**\n * Define an extension that can record the changes in the editor.\n */\nfunction defineCommitRecorder(commitRecorder: CommitRecorder): PlainExtension {\n const key = new PluginKey<DecorationSet>('prosekit-commit-recorder')\n\n return definePlugin(\n new ProseMirrorPlugin({\n key,\n state: {\n init: (_, state): void => {\n commitRecorder.init(state.doc)\n },\n apply: (tr): void => {\n commitRecorder.apply(tr)\n },\n },\n }),\n )\n}\n\nexport {\n CommitRecorder,\n defineCommitRecorder,\n defineCommitViewer,\n type Commit,\n}\n"],"mappings":";;;;;;;;AAkDA,SAAS,WACP,KACA,QACA,OACmB;AAOnB,QANgB,UAAU,OAAO,OAAO,CAChB,SACtB,KACA,MAAM,KAAK,SAAS,KAAK,QAAQ,CAAC,EAClC,KACD,CACc;;AAGjB,SAAS,gBAAgB,MAA+B;AAEtD,QADiB,KAAK,IAAI,cACV,cAAc,MAAM;;AAGtC,SAAS,sBACP,OAC0C;CAE1C,IAAI,EAAE,WAAW,SAAS,YAAY;AAEtC,QAAO,YAAY,KAAK,UAAU,KAAK,QAAQ,eAAe,GAAG;AAC/D;AACA;AACA,YAAU,QAAQ,MAAM,EAAE,CAAC;;AAI7B,KAAI,QAAQ,eAAe,EACzB,QAAO,EAAE;AAaX,KAAI,YAAY,KAAK,UAAU,KAAK,QAAQ,eAAe,GAAG;EAC5D,MAAM,OAAO,SAAS,KAAK,CA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SAAS,MAAM;MAE7B;GACF,CAAC;GACF;;;;;AAMJ,SAAS,mBAAmB,QAAgC;AAC1D,QAAO,MACL,mBAAmB,EAAE,YAAY,OAAO,KAAK,CAAC,EAC9C,uBAAuB,OAAO,CAC/B;;AAGH,IAAM,iBAAN,MAAqB;;gBACsB;aACH;eACd,EAAE;;;;;;CAM1B,SAAwB;AACtB,MACE,CAAC,KAAK,UACH,CAAC,KAAK,OACN,KAAK,MAAM,WAAW,KACtB,KAAK,OAAO,GAAG,KAAK,IAAI,CAE3B,QAAO;EAGT,MAAMC,SAAiB;GACrB,KAAK,aAAa,KAAK,IAAI;GAC3B,QAAQ,aAAa,KAAK,OAAO;GACjC,OAAO,KAAK,MAAM,KAAK,SAAS,KAAK,QAAQ,CAAa;GAC3D;AACD,OAAK,KAAK,KAAK,IAAI;AACnB,SAAO;;;;;CAMT,KAAK,KAA4B;AAC/B,OAAK,MAAM;AACX,OAAK,SAAS;AACd,OAAK,QAAQ,EAAE;;;;;CAMjB,MAAM,IAAuB;AAC3B,OAAK,MAAM,KAAK,GAAG,GAAG,MAAM;AAC5B,OAAK,MAAM,GAAG;;;;;;AAOlB,SAAS,qBAAqB,gBAAgD;AAG5E,QAAO,aACL,IAAI,kBAAkB;EACpB,KAJQ,IAAI,UAAyB,2BAA2B;EAKhE,OAAO;GACL,OAAO,GAAG,UAAgB;AACxB,mBAAe,KAAK,MAAM,IAAI;;GAEhC,QAAQ,OAAa;AACnB,mBAAe,MAAM,GAAG;;GAE3B;EACF,CAAC,CACH"}
1
+ {"version":3,"file":"prosekit-extensions-commit.js","names":[],"sources":["../src/commit/index.ts"],"sourcesContent":["import { defineDefaultState, definePlugin, jsonFromNode, union, type NodeJSON, type PlainExtension, type StepJSON } from '@prosekit/core'\nimport { DOMSerializer, Fragment, Slice, type ProseMirrorNode } from '@prosekit/pm/model'\nimport { PluginKey, ProseMirrorPlugin, type Transaction } from '@prosekit/pm/state'\nimport { Step } from '@prosekit/pm/transform'\nimport { Decoration, DecorationSet, type EditorView } from '@prosekit/pm/view'\nimport { ChangeSet, type Change } from 'prosemirror-changeset'\n\n/**\n * A JSON representation of a commit.\n */\ninterface Commit {\n /**\n * The current doc node in the JSON format\n */\n doc: NodeJSON\n /**\n * The parent node in the JSON format\n */\n parent: NodeJSON\n /**\n * An array of steps in the JSON format that transform the parent node to the\n * current doc node.\n */\n steps: StepJSON[]\n}\n\nfunction getChanges(\n doc: ProseMirrorNode,\n parent: ProseMirrorNode,\n steps: Step[],\n): readonly Change[] {\n const initSet = ChangeSet.create(parent)\n const currSet = initSet.addSteps(\n doc,\n steps.map((step) => step.getMap()),\n null,\n )\n return currSet.changes\n}\n\nfunction renderDivWeight(view: EditorView): HTMLElement {\n const document = view.dom.ownerDocument\n return document.createElement('div')\n}\n\nfunction decorateDeletionSlice(\n slice: Slice,\n): Array<(view: EditorView) => HTMLElement> {\n // Get the fragment of the deleted content\n let { openStart, openEnd, content } = slice\n\n while (openStart > 0 && openEnd > 0 && content.childCount === 1) {\n openStart--\n openEnd--\n content = content.child(0).content\n }\n\n // Nothing to render\n if (content.childCount === 0) {\n return []\n }\n\n // For example, if the slice is\n // {\n // openStart: 1,\n // openEnd: 1,\n // content: <p>Hello</p><p>World</p>\n // }\n // We should render the following decorations:\n // <span>Hello</span>\n // <div></div>\n // <span>World</span>\n if (openStart > 0 && openEnd > 0 && content.childCount === 2) {\n const head = Fragment.from([content.child(0)])\n const tail = Fragment.from([content.child(1)])\n return [\n ...decorateDeletionSlice(new Slice(head, openStart, openStart)),\n renderDivWeight,\n ...decorateDeletionSlice(new Slice(tail, openEnd, openEnd)),\n ]\n }\n\n // For example, if the slice is\n // {\n // openStart: 1,\n // openEnd: 0,\n // content: <p>Hello</p><p>World</p>\n // }\n // We should render the following decorations:\n // <span>Hello</span>\n // <div><p>World</p></div>\n if (openStart > 0 && content.childCount >= 2) {\n const nodes = content.content\n const head = Fragment.from(nodes.slice(0, 1))\n const body = Fragment.from(nodes.slice(1))\n\n return [\n ...decorateDeletionSlice(new Slice(head, openStart, openStart)),\n ...decorateDeletionSlice(new Slice(body, 0, openEnd)),\n ]\n }\n\n // For example, if the slice is\n // {\n // openStart: 0,\n // openEnd: 1,\n // content: <p>Hello</p><p>World</p>\n // }\n // We should render the following decorations:\n // <div><p>Hello</p></div>\n // <span>World</span>\n if (openEnd > 0 && content.childCount >= 2) {\n const nodes = content.content\n const body = Fragment.from(nodes.slice(0, -1))\n const tail = Fragment.from(nodes.slice(-1))\n return [\n ...decorateDeletionSlice(new Slice(body, openStart, 0)),\n ...decorateDeletionSlice(new Slice(tail, openEnd, openEnd)),\n ]\n }\n\n const schema = content.child(0).type.schema\n const isInline = content.child(0).isInline\n\n const render = (view: EditorView): HTMLElement => {\n const document = view.dom.ownerDocument\n\n // Render the fragment to HTML\n const element = document.createElement(isInline ? 'span' : 'div')\n const serializer = DOMSerializer.fromSchema(schema)\n serializer.serializeFragment(content, { document }, element)\n\n // Add the class to the element\n element.classList.add('prosekit-commit-deletion')\n return element\n }\n\n return [render]\n}\n\nfunction decorateDeletion(\n /** The doc node before the deletion */\n doc: ProseMirrorNode,\n /** The start position of the deleted text in the doc node */\n from: number,\n /** The end position of the deleted text in the doc node */\n to: number,\n /** The insert position of the decoration in the doc node after the change */\n pos: number,\n): Decoration[] {\n const slice = doc.slice(from, to)\n\n const renders = decorateDeletionSlice(slice)\n const count = renders.length\n\n return renders.map((render, index) =>\n Decoration.widget(pos, render, {\n side: -20 - count + index,\n // Ensure the text in the decoration is able to be selected.\n ignoreSelection: true,\n })\n )\n}\n\nfunction decorateAddition(\n /** The start position of the inserted text in the doc node */\n from: number,\n /** The end position of the inserted text in the doc node */\n to: number,\n): Decoration {\n return Decoration.inline(from, to, { class: 'prosekit-commit-addition' })\n}\n\nfunction decorateChange(prev: ProseMirrorNode, change: Change): Decoration[] {\n const { fromA, toA, fromB, toB } = change\n const decorations: Decoration[] = []\n\n if (fromA < toA) {\n decorations.push(...decorateDeletion(prev, fromA, toA, fromB))\n }\n if (fromB < toB) {\n decorations.push(decorateAddition(fromB, toB))\n }\n\n return decorations\n}\n\nfunction decorateCommit(\n doc: ProseMirrorNode,\n parent: ProseMirrorNode,\n steps: Step[],\n): DecorationSet {\n const changes = getChanges(doc, parent, steps)\n const decorations = changes.flatMap((change) => decorateChange(parent, change))\n return DecorationSet.create(doc, decorations)\n}\n\nfunction defineCommitDecoration(commit: Commit): PlainExtension {\n const key = new PluginKey<DecorationSet>('prosekit-commit-decoration')\n\n return definePlugin(({ schema }): ProseMirrorPlugin => {\n const parent = schema.nodeFromJSON(commit.parent)\n const steps = commit.steps.map((step) => Step.fromJSON(schema, step))\n\n return new ProseMirrorPlugin({\n key,\n state: {\n init: (_, instance): DecorationSet => {\n return decorateCommit(instance.doc, parent, steps)\n },\n apply: (tr, deco: DecorationSet): DecorationSet => {\n return deco.map(tr.mapping, tr.doc)\n },\n },\n props: {\n decorations: (state): DecorationSet | undefined => {\n return key.getState(state)\n },\n },\n })\n })\n}\n\n/**\n * Define an extension to display the changes from the given commit in the editor.\n */\nfunction defineCommitViewer(commit: Commit): PlainExtension {\n return union(\n defineDefaultState({ defaultContent: commit.doc }),\n defineCommitDecoration(commit),\n )\n}\n\nclass CommitRecorder {\n private parent: ProseMirrorNode | null = null\n private doc: ProseMirrorNode | null = null\n private steps: Step[] = []\n\n /**\n * Return a commit object including all changes since the last commit. `null`\n * will be returned if there is no change.\n */\n commit(): Commit | null {\n if (\n !this.parent\n || !this.doc\n || this.steps.length === 0\n || this.parent.eq(this.doc)\n ) {\n return null\n }\n\n const commit: Commit = {\n doc: jsonFromNode(this.doc),\n parent: jsonFromNode(this.parent),\n steps: this.steps.map((step) => step.toJSON() as StepJSON),\n }\n this.init(this.doc)\n return commit\n }\n\n /**\n * @internal\n */\n init(doc: ProseMirrorNode): void {\n this.doc = doc\n this.parent = doc\n this.steps = []\n }\n\n /**\n * @internal\n */\n apply(tr: Transaction): void {\n this.steps.push(...tr.steps)\n this.doc = tr.doc\n }\n}\n\n/**\n * Define an extension that can record the changes in the editor.\n */\nfunction defineCommitRecorder(commitRecorder: CommitRecorder): PlainExtension {\n const key = new PluginKey<DecorationSet>('prosekit-commit-recorder')\n\n return definePlugin(\n new ProseMirrorPlugin({\n key,\n state: {\n init: (_, state): void => {\n commitRecorder.init(state.doc)\n },\n apply: (tr): void => {\n commitRecorder.apply(tr)\n },\n },\n }),\n )\n}\n\nexport { CommitRecorder, defineCommitRecorder, defineCommitViewer, type Commit }\n"],"mappings":";;;;;;;;AA0BA,SAAS,WACP,KACA,QACA,OACmB;AAOnB,QANgB,UAAU,OAAO,OAAO,CAChB,SACtB,KACA,MAAM,KAAK,SAAS,KAAK,QAAQ,CAAC,EAClC,KACD,CACc;;AAGjB,SAAS,gBAAgB,MAA+B;AAEtD,QADiB,KAAK,IAAI,cACV,cAAc,MAAM;;AAGtC,SAAS,sBACP,OAC0C;CAE1C,IAAI,EAAE,WAAW,SAAS,YAAY;AAEtC,QAAO,YAAY,KAAK,UAAU,KAAK,QAAQ,eAAe,GAAG;AAC/D;AACA;AACA,YAAU,QAAQ,MAAM,EAAE,CAAC;;AAI7B,KAAI,QAAQ,eAAe,EACzB,QAAO,EAAE;AAaX,KAAI,YAAY,KAAK,UAAU,KAAK,QAAQ,eAAe,GAAG;EAC5D,MAAM,OAAO,SAAS,KAAK,CAAC,QAAQ,MAAM,EAAE,CAAC,CAAC;EAC9C,MAAM,OAAO,SAAS,KAAK,CAAC,QAAQ,MAAM,EAAE,CAAC,CAAC;AAC9C,SAAO;GACL,GAAG,sBAAsB,IAAI,MAAM,MAAM,WAAW,UAAU,CAAC;GAC/D;GACA,GAAG,sBAAsB,IAAI,MAAM,MAAM,SAAS,QAAQ,CAAC;GAC5D;;AAYH,KAAI,YAAY,KAAK,QAAQ,cAAc,GAAG;EAC5C,MAAM,QAAQ,QAAQ;EACtB,MAAM,OAAO,SAAS,KAAK,MAAM,MAAM,GAAG,EAAE,CAAC;EAC7C,MAAM,OAAO,SAAS,KAAK,MA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AAK,OAAO;GACjC,OAAO,KAAK,MAAM,KAAK,SAAS,KAAK,QAAQ,CAAa;GAC3D;AACD,OAAK,KAAK,KAAK,IAAI;AACnB,SAAO;;;;;CAMT,KAAK,KAA4B;AAC/B,OAAK,MAAM;AACX,OAAK,SAAS;AACd,OAAK,QAAQ,EAAE;;;;;CAMjB,MAAM,IAAuB;AAC3B,OAAK,MAAM,KAAK,GAAG,GAAG,MAAM;AAC5B,OAAK,MAAM,GAAG;;;;;;AAOlB,SAAS,qBAAqB,gBAAgD;AAG5E,QAAO,aACL,IAAI,kBAAkB;EACpB,KAJQ,IAAI,UAAyB,2BAA2B;EAKhE,OAAO;GACL,OAAO,GAAG,UAAgB;AACxB,mBAAe,KAAK,MAAM,IAAI;;GAEhC,QAAQ,OAAa;AACnB,mBAAe,MAAM,GAAG;;GAE3B;EACF,CAAC,CACH"}
@@ -2,7 +2,6 @@ import { Extension } from "@prosekit/core";
2
2
  import { Attrs } from "@prosekit/pm/model";
3
3
 
4
4
  //#region src/doc/index.d.ts
5
-
6
5
  /**
7
6
  * @internal
8
7
  */
@@ -1 +1 @@
1
- {"version":3,"file":"prosekit-extensions-doc.d.ts","names":[],"sources":["../src/doc/index.ts"],"sourcesContent":[],"mappings":";;;;;;;AASA;AAKgB,KALJ,YAAA,GAAe,SAKE,CAAA;;SALwB;;;;;;iBAKrC,SAAA,CAAA,GAAa"}
1
+ {"version":3,"file":"prosekit-extensions-doc.d.ts","names":[],"sources":["../src/doc/index.ts"],"mappings":";;;;;;AAMA;KAAY,YAAA,GAAe,SAAA;EAAY,KAAA;IAAS,GAAA,EAAK,KAAA;EAAA;AAAA;;;;iBAKrC,SAAA,CAAA,GAAa,YAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"prosekit-extensions-doc.js","names":[],"sources":["../src/doc/index.ts"],"sourcesContent":["import {\n defineNodeSpec,\n type Extension,\n} from '@prosekit/core'\nimport type { Attrs } from '@prosekit/pm/model'\n\n/**\n * @internal\n */\nexport type DocExtension = Extension<{ Nodes: { doc: Attrs } }>\n\n/**\n * @public\n */\nexport function defineDoc(): DocExtension {\n return defineNodeSpec({\n name: 'doc',\n content: 'block+',\n topNode: true,\n })\n}\n"],"mappings":";;;;;;AAcA,SAAgB,YAA0B;AACxC,QAAO,eAAe;EACpB,MAAM;EACN,SAAS;EACT,SAAS;EACV,CAAC"}
1
+ {"version":3,"file":"prosekit-extensions-doc.js","names":[],"sources":["../src/doc/index.ts"],"sourcesContent":["import { defineNodeSpec, type Extension } from '@prosekit/core'\nimport type { Attrs } from '@prosekit/pm/model'\n\n/**\n * @internal\n */\nexport type DocExtension = Extension<{ Nodes: { doc: Attrs } }>\n\n/**\n * @public\n */\nexport function defineDoc(): DocExtension {\n return defineNodeSpec({\n name: 'doc',\n content: 'block+',\n topNode: true,\n })\n}\n"],"mappings":";;;;;;AAWA,SAAgB,YAA0B;AACxC,QAAO,eAAe;EACpB,MAAM;EACN,SAAS;EACT,SAAS;EACV,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"prosekit-extensions-drop-cursor.d.ts","names":[],"sources":["../src/drop-cursor/drop-cursor.ts"],"sourcesContent":[],"mappings":";;;UAMiB,iBAAA;;AAAjB;AAwBA;AAWA;;;;;;;;;;;;;;;;;KAXY,mBAAA,GAAsB;;;;;;;;;;iBAWlB,gBAAA,WACJ,oBACT"}
1
+ {"version":3,"file":"prosekit-extensions-drop-cursor.d.ts","names":[],"sources":["../src/drop-cursor/drop-cursor.ts"],"mappings":";;;UAGiB,iBAAA;;AAAjB;;;;EAME,KAAA;EAOA;;;;AAWF;EAXE,KAAA;;;;EAKA,KAAA;AAAA;;;;KAMU,mBAAA,GAAsB,cAAA;;;;;;;;;;iBAWlB,gBAAA,CACd,OAAA,GAAU,iBAAA,GACT,mBAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"prosekit-extensions-drop-cursor.js","names":[],"sources":["../src/drop-cursor/drop-cursor.ts"],"sourcesContent":["import {\n definePlugin,\n type PlainExtension,\n} from '@prosekit/core'\nimport { dropCursor } from 'prosemirror-dropcursor'\n\nexport interface DropCursorOptions {\n /**\n * The color of the cursor. Use `false` to apply no color and rely only on class.\n *\n * @default 'black'\n */\n color?: string | false\n\n /**\n * The precise width of the cursor in pixels.\n *\n * @default 1\n */\n width?: number\n\n /**\n * A CSS class name to add to the cursor element.\n */\n class?: string\n}\n\n/**\n * @internal\n */\nexport type DropCursorExtension = PlainExtension\n\n/**\n * Show up a decoration at the drop position when something is dragged over the editor.\n *\n * See [prosemirror-dropcursor](https://github.com/ProseMirror/prosemirror-dropcursor) for more information.\n *\n * You probably want to use `<DropIndicator />` component instead of this extension.\n *\n * @public\n */\nexport function defineDropCursor(\n options?: DropCursorOptions,\n): DropCursorExtension {\n return definePlugin(() => dropCursor(options))\n}\n"],"mappings":";;;;;;;;;;;;;AAyCA,SAAgB,iBACd,SACqB;AACrB,QAAO,mBAAmB,WAAW,QAAQ,CAAC"}
1
+ {"version":3,"file":"prosekit-extensions-drop-cursor.js","names":[],"sources":["../src/drop-cursor/drop-cursor.ts"],"sourcesContent":["import { definePlugin, type PlainExtension } from '@prosekit/core'\nimport { dropCursor } from 'prosemirror-dropcursor'\n\nexport interface DropCursorOptions {\n /**\n * The color of the cursor. Use `false` to apply no color and rely only on class.\n *\n * @default 'black'\n */\n color?: string | false\n\n /**\n * The precise width of the cursor in pixels.\n *\n * @default 1\n */\n width?: number\n\n /**\n * A CSS class name to add to the cursor element.\n */\n class?: string\n}\n\n/**\n * @internal\n */\nexport type DropCursorExtension = PlainExtension\n\n/**\n * Show up a decoration at the drop position when something is dragged over the editor.\n *\n * See [prosemirror-dropcursor](https://github.com/ProseMirror/prosemirror-dropcursor) for more information.\n *\n * You probably want to use `<DropIndicator />` component instead of this extension.\n *\n * @public\n */\nexport function defineDropCursor(\n options?: DropCursorOptions,\n): DropCursorExtension {\n return definePlugin(() => dropCursor(options))\n}\n"],"mappings":";;;;;;;;;;;;;AAsCA,SAAgB,iBACd,SACqB;AACrB,QAAO,mBAAmB,WAAW,QAAQ,CAAC"}
@@ -2,7 +2,6 @@ import { PlainExtension } from "@prosekit/core";
2
2
  import { DragEventHandler, DragEventHandlerOptions, DropIndicatorPluginOptions, Line, Point, ShowHandler, ShowHandlerOptions, ViewDragging } from "prosemirror-drop-indicator";
3
3
 
4
4
  //#region src/drop-indicator/drop-indicator.d.ts
5
-
6
5
  /**
7
6
  * @internal
8
7
  */
@@ -1 +1 @@
1
- {"version":3,"file":"prosekit-extensions-drop-indicator.d.ts","names":[],"sources":["../src/drop-indicator/drop-indicator.ts"],"sourcesContent":[],"mappings":";;;;;;;AAQA;AAegB,KAfJ,sBAAA,GAAyB,cAgBzB;AAUZ;;;;;;;;;;;;;iBAXgB,mBAAA,WACJ,uBACT;;;;;;UASc,oBAAA,SAA6B"}
1
+ {"version":3,"file":"prosekit-extensions-drop-indicator.d.ts","names":[],"sources":["../src/drop-indicator/drop-indicator.ts"],"mappings":";;;;;;AAQA;KAAY,sBAAA,GAAyB,cAAA;;;;AAerC;;;;;;;;;AAWA;iBAXgB,mBAAA,CACd,OAAA,GAAU,oBAAA,GACT,sBAAA;;;;;;UASc,oBAAA,SAA6B,0BAAA"}
@@ -1,3 +1,3 @@
1
- import { t as defineDropIndicator } from "./drop-indicator-B1QHFb5m.js";
1
+ import { t as defineDropIndicator } from "./drop-indicator-B_oMfeVP.js";
2
2
 
3
3
  export { defineDropIndicator };
@@ -3,7 +3,6 @@ import { EditorState, Transaction } from "@prosekit/pm/state";
3
3
  import { Attrs, NodeType } from "@prosekit/pm/model";
4
4
 
5
5
  //#region src/enter-rule/index.d.ts
6
-
7
6
  /**
8
7
  * @public
9
8
  *
@@ -1 +1 @@
1
- {"version":3,"file":"prosekit-extensions-enter-rule.d.ts","names":[],"sources":["../src/enter-rule/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;AA8BA;AAyBA;AAOA;AAwBiB,UAxDA,uBAAA,CAwDyB;EAIjC;;;EAWyB,KAAA,EAnEzB,WAmEy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AA4B,cAAA"}
@@ -1,3 +1,3 @@
1
- import { n as defineTextBlockEnterRule, t as defineEnterRule } from "./enter-rule-CzWOZF_Z.js";
1
+ import { n as defineTextBlockEnterRule, t as defineEnterRule } from "./enter-rule-D-p4ykfv.js";
2
2
 
3
3
  export { defineEnterRule, defineTextBlockEnterRule };
@@ -1,2 +1,2 @@
1
- import { a as FilePasteHandler, c as FileDropHandler, i as UploaderOptions, l as FileDropHandlerOptions, n as UploadTask, o as FilePasteHandlerOptions, r as Uploader, s as defineFilePasteHandler, t as UploadProgress, u as defineFileDropHandler } from "./index-oIc1a2f2.js";
1
+ import { a as FilePasteHandler, c as FileDropHandler, i as UploaderOptions, l as FileDropHandlerOptions, n as UploadTask, o as FilePasteHandlerOptions, r as Uploader, s as defineFilePasteHandler, t as UploadProgress, u as defineFileDropHandler } from "./index-cp1u4e0e.js";
2
2
  export { FileDropHandler, FileDropHandlerOptions, FilePasteHandler, FilePasteHandlerOptions, UploadProgress, UploadTask, Uploader, UploaderOptions, defineFileDropHandler, defineFilePasteHandler };
@@ -1,3 +1,3 @@
1
- import { n as defineFilePasteHandler, r as defineFileDropHandler, t as UploadTask } from "./file-DrfcSid-.js";
1
+ import { n as defineFilePasteHandler, r as defineFileDropHandler, t as UploadTask } from "./file-iLVR0eM0.js";
2
2
 
3
3
  export { UploadTask, defineFileDropHandler, defineFilePasteHandler };
@@ -1,7 +1,6 @@
1
1
  import { PlainExtension } from "@prosekit/core";
2
2
 
3
3
  //#region src/gap-cursor/gap-cursor.d.ts
4
-
5
4
  /**
6
5
  * @internal
7
6
  */
@@ -1 +1 @@
1
- {"version":3,"file":"prosekit-extensions-gap-cursor.d.ts","names":[],"sources":["../src/gap-cursor/gap-cursor.ts"],"sourcesContent":[],"mappings":";;;;;;AASA;AAgBgB,KAhBJ,kBAAA,GAAqB,cAgBE;;;;;;;;;;;;;;;iBAAnB,eAAA,CAAA,GAAmB"}
1
+ {"version":3,"file":"prosekit-extensions-gap-cursor.d.ts","names":[],"sources":["../src/gap-cursor/gap-cursor.ts"],"mappings":";;;;;AAMA;KAAY,kBAAA,GAAqB,cAAA;;;;AAgBjC;;;;;;;;;;;iBAAgB,eAAA,CAAA,GAAmB,kBAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"prosekit-extensions-gap-cursor.js","names":[],"sources":["../src/gap-cursor/gap-cursor.ts"],"sourcesContent":["import {\n definePlugin,\n type PlainExtension,\n} from '@prosekit/core'\nimport { gapCursor } from 'prosemirror-gapcursor'\n\n/**\n * @internal\n */\nexport type GapCursorExtension = PlainExtension\n\n/**\n * Capture clicks near and arrow-key-motion past places that don't have a\n * normally selectable position nearby, and create a gap cursor selection for\n * them. The cursor is drawn as an element with class `ProseMirror-gapcursor`.\n *\n * You can either include `prosekit/extensions/gap-cursor.css` or add your own\n * styles to make it visible.\n *\n * See\n * [prosemirror-gapcursor](https://github.com/ProseMirror/prosemirror-gapcursor)\n * for more information.\n *\n * @public\n */\nexport function defineGapCursor(): GapCursorExtension {\n return definePlugin(() => gapCursor())\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAyBA,SAAgB,kBAAsC;AACpD,QAAO,mBAAmB,WAAW,CAAC"}
1
+ {"version":3,"file":"prosekit-extensions-gap-cursor.js","names":[],"sources":["../src/gap-cursor/gap-cursor.ts"],"sourcesContent":["import { definePlugin, type PlainExtension } from '@prosekit/core'\nimport { gapCursor } from 'prosemirror-gapcursor'\n\n/**\n * @internal\n */\nexport type GapCursorExtension = PlainExtension\n\n/**\n * Capture clicks near and arrow-key-motion past places that don't have a\n * normally selectable position nearby, and create a gap cursor selection for\n * them. The cursor is drawn as an element with class `ProseMirror-gapcursor`.\n *\n * You can either include `prosekit/extensions/gap-cursor.css` or add your own\n * styles to make it visible.\n *\n * See\n * [prosemirror-gapcursor](https://github.com/ProseMirror/prosemirror-gapcursor)\n * for more information.\n *\n * @public\n */\nexport function defineGapCursor(): GapCursorExtension {\n return definePlugin(() => gapCursor())\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAsBA,SAAgB,kBAAsC;AACpD,QAAO,mBAAmB,WAAW,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"prosekit-extensions-hard-break.d.ts","names":[],"sources":["../src/hard-break/hard-break-commands.ts","../src/hard-break/hard-break-spec.ts","../src/hard-break/hard-break.ts","../src/hard-break/hard-break-keymap.ts"],"sourcesContent":[],"mappings":";;;;;;;;AAUY,KAAA,0BAAA,GAA6B,SAAA,CAAA;EAgBzB,QAAA,EAAA;;;;;AERhB;;AAC2B,iBFOX,uBAAA,CAAA,CEPW,EFOgB,0BEPhB;;;;;;AFTf,KCDA,sBAAA,GAAyB,SDCI,CAAA;EAgBzB,KAAA,EAAA;eCfD;;;AAFf;AASA;;iBAAgB,mBAAA,CAAA,GAAuB;;;;;ADRvC;AAgBgB,KERJ,kBAAA,GAAqB,KFQM,CAAA,CEPpC,wBAAwB;ADV3B;AASA;;iBCOgB,eAAA,CAAA,GAAmB;;;;;;iBCfnB,qBAAA,CAAA,GAAyB"}
1
+ {"version":3,"file":"prosekit-extensions-hard-break.d.ts","names":[],"sources":["../src/hard-break/hard-break-commands.ts","../src/hard-break/hard-break-spec.ts","../src/hard-break/hard-break.ts","../src/hard-break/hard-break-keymap.ts"],"mappings":";;;;;;;;KAMY,0BAAA,GAA6B,SAAA;EACvC,QAAA;IACE,eAAA;EAAA;AAAA;AAcJ;;;AAAA,iBAAgB,uBAAA,CAAA,GAA2B,0BAAA;;;;;;KChB/B,sBAAA,GAAyB,SAAA;EACnC,KAAA;IACE,SAAA,EAAW,KAAA;EAAA;AAAA;;;;iBAOC,mBAAA,CAAA,GAAuB,sBAAA;;;;;ADTvC;KEGY,kBAAA,GAAqB,KAAA,EAC9B,sBAAA,EAAwB,0BAAA;;;;iBAMX,eAAA,CAAA,GAAmB,kBAAA;;;;;;iBCTnB,qBAAA,CAAA,GAAyB,cAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"prosekit-extensions-hard-break.js","names":[],"sources":["../src/hard-break/hard-break-commands.ts","../src/hard-break/hard-break-keymap.ts","../src/hard-break/hard-break-spec.ts","../src/hard-break/hard-break.ts"],"sourcesContent":["import {\n defineCommands,\n insertNode,\n type Extension,\n} from '@prosekit/core'\nimport type { Command } from '@prosekit/pm/state'\n\n/**\n * @internal\n */\nexport type HardBreakCommandsExtension = Extension<{\n Commands: {\n insertHardBreak: []\n }\n}>\n\n/**\n * @internal\n */\nexport function insertHardBreak(): Command {\n return insertNode({ type: 'hardBreak' })\n}\n\n/**\n * @internal\n */\nexport function defineHardBreakCommands(): HardBreakCommandsExtension {\n return defineCommands({\n insertHardBreak: insertHardBreak,\n })\n}\n","import {\n defineKeymap,\n type PlainExtension,\n} from '@prosekit/core'\n\nimport { insertHardBreak } from './hard-break-commands'\n\n/**\n * @internal\n */\nexport function defineHardBreakKeymap(): PlainExtension {\n return defineKeymap({\n 'Mod-Enter': insertHardBreak(),\n 'Shift-Enter': insertHardBreak(),\n })\n}\n","import {\n defineNodeSpec,\n type Extension,\n} from '@prosekit/core'\nimport type { Attrs } from '@prosekit/pm/model'\n\n/**\n * @internal\n */\nexport type HardBreakSpecExtension = Extension<{\n Nodes: {\n hardBreak: Attrs\n }\n}>\n\n/**\n * @internal\n */\nexport function defineHardBreakSpec(): HardBreakSpecExtension {\n return defineNodeSpec({\n name: 'hardBreak',\n inline: true,\n selectable: false,\n leafText: () => '\\n',\n group: 'inline',\n parseDOM: [{ tag: 'br' }],\n toDOM() {\n return ['br']\n },\n })\n}\n","import {\n union,\n type Union,\n} from '@prosekit/core'\n\nimport {\n defineHardBreakCommands,\n type HardBreakCommandsExtension,\n} from './hard-break-commands'\nimport { defineHardBreakKeymap } from './hard-break-keymap'\nimport {\n defineHardBreakSpec,\n type HardBreakSpecExtension,\n} from './hard-break-spec'\n\n/**\n * @internal\n */\nexport type HardBreakExtension = Union<\n [HardBreakSpecExtension, HardBreakCommandsExtension]\n>\n\n/**\n * @public\n */\nexport function defineHardBreak(): HardBreakExtension {\n return union(\n defineHardBreakSpec(),\n defineHardBreakKeymap(),\n defineHardBreakCommands(),\n )\n}\n"],"mappings":";;;;;;AAmBA,SAAgB,kBAA2B;AACzC,QAAO,WAAW,EAAE,MAAM,aAAa,CAAC;;;;;AAM1C,SAAgB,0BAAsD;AACpE,QAAO,eAAe,EACH,iBAClB,CAAC;;;;;;;;ACnBJ,SAAgB,wBAAwC;AACtD,QAAO,aAAa;EAClB,aAAa,iBAAiB;EAC9B,eAAe,iBAAiB;EACjC,CAAC;;;;;;;;ACIJ,SAAgB,sBAA8C;AAC5D,QAAO,eAAe;EACpB,MAAM;EACN,QAAQ;EACR,YAAY;EACZ,gBAAgB;EAChB,OAAO;EACP,UAAU,CAAC,EAAE,KAAK,MAAM,CAAC;EACzB,QAAQ;AACN,UAAO,CAAC,KAAK;;EAEhB,CAAC;;;;;;;;ACJJ,SAAgB,kBAAsC;AACpD,QAAO,MACL,qBAAqB,EACrB,uBAAuB,EACvB,yBAAyB,CAC1B"}
1
+ {"version":3,"file":"prosekit-extensions-hard-break.js","names":[],"sources":["../src/hard-break/hard-break-commands.ts","../src/hard-break/hard-break-keymap.ts","../src/hard-break/hard-break-spec.ts","../src/hard-break/hard-break.ts"],"sourcesContent":["import { defineCommands, insertNode, type Extension } from '@prosekit/core'\nimport type { Command } from '@prosekit/pm/state'\n\n/**\n * @internal\n */\nexport type HardBreakCommandsExtension = Extension<{\n Commands: {\n insertHardBreak: []\n }\n}>\n\n/**\n * @internal\n */\nexport function insertHardBreak(): Command {\n return insertNode({ type: 'hardBreak' })\n}\n\n/**\n * @internal\n */\nexport function defineHardBreakCommands(): HardBreakCommandsExtension {\n return defineCommands({\n insertHardBreak: insertHardBreak,\n })\n}\n","import { defineKeymap, type PlainExtension } from '@prosekit/core'\n\nimport { insertHardBreak } from './hard-break-commands'\n\n/**\n * @internal\n */\nexport function defineHardBreakKeymap(): PlainExtension {\n return defineKeymap({\n 'Mod-Enter': insertHardBreak(),\n 'Shift-Enter': insertHardBreak(),\n })\n}\n","import { defineNodeSpec, type Extension } from '@prosekit/core'\nimport type { Attrs } from '@prosekit/pm/model'\n\n/**\n * @internal\n */\nexport type HardBreakSpecExtension = Extension<{\n Nodes: {\n hardBreak: Attrs\n }\n}>\n\n/**\n * @internal\n */\nexport function defineHardBreakSpec(): HardBreakSpecExtension {\n return defineNodeSpec({\n name: 'hardBreak',\n inline: true,\n selectable: false,\n leafText: () => '\\n',\n group: 'inline',\n parseDOM: [{ tag: 'br' }],\n toDOM() {\n return ['br']\n },\n })\n}\n","import { union, type Union } from '@prosekit/core'\n\nimport { defineHardBreakCommands, type HardBreakCommandsExtension } from './hard-break-commands'\nimport { defineHardBreakKeymap } from './hard-break-keymap'\nimport { defineHardBreakSpec, type HardBreakSpecExtension } from './hard-break-spec'\n\n/**\n * @internal\n */\nexport type HardBreakExtension = Union<\n [HardBreakSpecExtension, HardBreakCommandsExtension]\n>\n\n/**\n * @public\n */\nexport function defineHardBreak(): HardBreakExtension {\n return union(\n defineHardBreakSpec(),\n defineHardBreakKeymap(),\n defineHardBreakCommands(),\n )\n}\n"],"mappings":";;;;;;AAeA,SAAgB,kBAA2B;AACzC,QAAO,WAAW,EAAE,MAAM,aAAa,CAAC;;;;;AAM1C,SAAgB,0BAAsD;AACpE,QAAO,eAAe,EACH,iBAClB,CAAC;;;;;;;;AClBJ,SAAgB,wBAAwC;AACtD,QAAO,aAAa;EAClB,aAAa,iBAAiB;EAC9B,eAAe,iBAAiB;EACjC,CAAC;;;;;;;;ACIJ,SAAgB,sBAA8C;AAC5D,QAAO,eAAe;EACpB,MAAM;EACN,QAAQ;EACR,YAAY;EACZ,gBAAgB;EAChB,OAAO;EACP,UAAU,CAAC,EAAE,KAAK,MAAM,CAAC;EACzB,QAAQ;AACN,UAAO,CAAC,KAAK;;EAEhB,CAAC;;;;;;;;ACVJ,SAAgB,kBAAsC;AACpD,QAAO,MACL,qBAAqB,EACrB,uBAAuB,EACvB,yBAAyB,CAC1B"}
@@ -1 +1 @@
1
- {"version":3,"file":"prosekit-extensions-heading.d.ts","names":[],"sources":["../src/heading/heading-types.ts","../src/heading/heading-commands.ts","../src/heading/heading-spec.ts","../src/heading/heading.ts","../src/heading/heading-input-rule.ts","../src/heading/heading-keymap.ts"],"sourcesContent":[],"mappings":";;;UAAiB,YAAA;;;;;;AAAjB;;KCaY,wBAAA,GAA2B;;IAA3B,UAAA,EAAA,CAAA,KAAA,GAEa,YAFW,GAAA,SAAA,CAAA;IAEX,aAAA,EAAA,CAAA,KAAA,GACG,YADH,GAAA,SAAA,CAAA;IACG,aAAA,EAAA,CAAA,KAAA,GACA,YADA,GAAA,SAAA,CAAA;EACA,CAAA;CAJW,CAAA;;AAWvC;;iBAAgB,qBAAA,CAAA,GAAyB;;;;ADxBzC;;KEUY,oBAAA,GAAuB;;IDGvB,OAAA,ECDC,YDCD;EAEa,CAAA;CACG,CAAA;;;;AAQZ,iBCLA,iBAAA,CAAA,CDKyB,ECLJ,oBDKI;;;ADxBzC;;;KGmBY,gBAAA,GAAmB,OAC5B,oBFPS,EEOa,wBFLA,CACG,CAAA;;;;AAQZ,iBEEA,aAAA,CAAA,CFFqB,EEEJ,gBFFQ;;;;;ADxBzC;;;;ACaY,iBGDI,sBAAA,CAAA,CHCoB,EGDM,cHCN;;;;;ADbpC;iBK6BgB,mBAAA,CAAA,GAAuB"}
1
+ {"version":3,"file":"prosekit-extensions-heading.d.ts","names":[],"sources":["../src/heading/heading-types.ts","../src/heading/heading-commands.ts","../src/heading/heading-spec.ts","../src/heading/heading.ts","../src/heading/heading-input-rule.ts","../src/heading/heading-keymap.ts"],"mappings":";;;UAAiB,YAAA;EACf,KAAA;AAAA;;;;AADF;;KCOY,wBAAA,GAA2B,SAAA;EACrC,QAAA;IACE,UAAA,GAAa,KAAA,GAAQ,YAAA;IACrB,aAAA,GAAgB,KAAA,GAAQ,YAAA;IACxB,aAAA,GAAgB,KAAA,GAAQ,YAAA;EAAA;AAAA;;;;iBAOZ,qBAAA,CAAA,GAAyB,wBAAA;;;;ADlBzC;;KEOY,oBAAA,GAAuB,SAAA;EACjC,KAAA;IACE,OAAA,EAAS,YAAA;EAAA;AAAA;;ADFb;;iBCSgB,iBAAA,CAAA,GAAqB,oBAAA;;;AFhBrC;;;AAAA,KGUY,gBAAA,GAAmB,KAAA,EAC5B,oBAAA,EAAsB,wBAAA;;AFJzB;;iBEUgB,aAAA,CAAA,GAAiB,gBAAA;;;;;AHjBjC;;;;iBIYgB,sBAAA,CAAA,GAA0B,cAAA;;;;;AJZ1C;iBKsBgB,mBAAA,CAAA,GAAuB,cAAA"}
@@ -1,4 +1,4 @@
1
- import { i as defineTextBlockInputRule } from "./input-rule-dmsb3j6w.js";
1
+ import { i as defineTextBlockInputRule } from "./input-rule-COGr_GBb.js";
2
2
  import { defineCommands, defineKeymap, defineNodeSpec, insertNode, isAtBlockStart, setBlockType, toggleNode, union, unsetBlockType, withSkipCodeBlock } from "@prosekit/core";
3
3
 
4
4
  //#region src/heading/heading-commands.ts
@@ -67,12 +67,12 @@ const backspaceUnsetHeading = (state, dispatch, view) => {
67
67
  */
68
68
  function defineHeadingKeymap() {
69
69
  return defineKeymap({
70
- "mod-alt-1": toggleHeadingKeybinding(1),
71
- "mod-alt-2": toggleHeadingKeybinding(2),
72
- "mod-alt-3": toggleHeadingKeybinding(3),
73
- "mod-alt-4": toggleHeadingKeybinding(4),
74
- "mod-alt-5": toggleHeadingKeybinding(5),
75
- "mod-alt-6": toggleHeadingKeybinding(6),
70
+ "Mod-Alt-1": toggleHeadingKeybinding(1),
71
+ "Mod-Alt-2": toggleHeadingKeybinding(2),
72
+ "Mod-Alt-3": toggleHeadingKeybinding(3),
73
+ "Mod-Alt-4": toggleHeadingKeybinding(4),
74
+ "Mod-Alt-5": toggleHeadingKeybinding(5),
75
+ "Mod-Alt-6": toggleHeadingKeybinding(6),
76
76
  "Backspace": backspaceUnsetHeading
77
77
  });
78
78
  }
@@ -1 +1 @@
1
- {"version":3,"file":"prosekit-extensions-heading.js","names":["backspaceUnsetHeading: Command"],"sources":["../src/heading/heading-commands.ts","../src/heading/heading-input-rule.ts","../src/heading/heading-keymap.ts","../src/heading/heading-spec.ts","../src/heading/heading.ts"],"sourcesContent":["import {\n defineCommands,\n insertNode,\n setBlockType,\n toggleNode,\n type Extension,\n} from '@prosekit/core'\n\nimport type { HeadingAttrs } from './heading-types'\n\n/**\n * @internal\n */\nexport type HeadingCommandsExtension = Extension<{\n Commands: {\n setHeading: [attrs?: HeadingAttrs | undefined]\n insertHeading: [attrs?: HeadingAttrs | undefined]\n toggleHeading: [attrs?: HeadingAttrs | undefined]\n }\n}>\n\n/**\n * @internal\n */\nexport function defineHeadingCommands(): HeadingCommandsExtension {\n return defineCommands({\n setHeading: (attrs?: HeadingAttrs) => {\n return setBlockType({ type: 'heading', attrs })\n },\n insertHeading: (attrs?: HeadingAttrs) => {\n return insertNode({ type: 'heading', attrs })\n },\n toggleHeading: (attrs?: HeadingAttrs) => {\n return toggleNode({ type: 'heading', attrs })\n },\n })\n}\n","import type { PlainExtension } from '@prosekit/core'\n\nimport { defineTextBlockInputRule } from '../input-rule'\n\nimport type { HeadingAttrs } from './heading-types'\n\n/**\n * Converts the text block to a heading when `#` is typed at the start of a new\n * line followed by a space.\n *\n * @internal\n */\nexport function defineHeadingInputRule(): PlainExtension {\n return defineTextBlockInputRule({\n regex: /^(#{1,6})\\s$/,\n type: 'heading',\n attrs: (match) => {\n const level: number = match[1]?.length ?? 1\n return { level } satisfies HeadingAttrs\n },\n })\n}\n","import {\n defineKeymap,\n isAtBlockStart,\n toggleNode,\n unsetBlockType,\n withSkipCodeBlock,\n type PlainExtension,\n} from '@prosekit/core'\nimport type { Command } from '@prosekit/pm/state'\n\nfunction toggleHeadingKeybinding(level: number): Command {\n return withSkipCodeBlock(toggleNode({ type: 'heading', attrs: { level } }))\n}\n\n/**\n * Set the block type to default (usually `paragraph`) when pressing Backspace at\n * the start of a heading block.\n */\nconst backspaceUnsetHeading: Command = (state, dispatch, view) => {\n const $pos = isAtBlockStart(state, view)\n if ($pos?.parent.type.name === 'heading') {\n return unsetBlockType()(state, dispatch, view)\n }\n return false\n}\n\n/**\n * @internal\n */\nexport function defineHeadingKeymap(): PlainExtension {\n return defineKeymap({\n 'mod-alt-1': toggleHeadingKeybinding(1),\n 'mod-alt-2': toggleHeadingKeybinding(2),\n 'mod-alt-3': toggleHeadingKeybinding(3),\n 'mod-alt-4': toggleHeadingKeybinding(4),\n 'mod-alt-5': toggleHeadingKeybinding(5),\n 'mod-alt-6': toggleHeadingKeybinding(6),\n 'Backspace': backspaceUnsetHeading,\n })\n}\n","import {\n defineNodeSpec,\n type Extension,\n} from '@prosekit/core'\n\nimport type { HeadingAttrs } from './heading-types'\n\n/**\n * @internal\n */\nexport type HeadingSpecExtension = Extension<{\n Nodes: {\n heading: HeadingAttrs\n }\n}>\n\n/**\n * @internal\n */\nexport function defineHeadingSpec(): HeadingSpecExtension {\n return defineNodeSpec({\n name: 'heading',\n attrs: { level: { default: 1, validate: 'number' } },\n content: 'inline*',\n group: 'block',\n defining: true,\n parseDOM: [\n { tag: 'h1', attrs: { level: 1 } },\n { tag: 'h2', attrs: { level: 2 } },\n { tag: 'h3', attrs: { level: 3 } },\n { tag: 'h4', attrs: { level: 4 } },\n { tag: 'h5', attrs: { level: 5 } },\n { tag: 'h6', attrs: { level: 6 } },\n ],\n toDOM(node) {\n return [`h${node.attrs.level}`, 0]\n },\n })\n}\n","import {\n union,\n type Union,\n} from '@prosekit/core'\n\nimport {\n defineHeadingCommands,\n type HeadingCommandsExtension,\n} from './heading-commands'\nimport { defineHeadingInputRule } from './heading-input-rule'\nimport { defineHeadingKeymap } from './heading-keymap'\nimport {\n defineHeadingSpec,\n type HeadingSpecExtension,\n} from './heading-spec'\n\n/**\n * @internal\n */\nexport type HeadingExtension = Union<\n [HeadingSpecExtension, HeadingCommandsExtension]\n>\n\n/**\n * @public\n */\nexport function defineHeading(): HeadingExtension {\n return union(\n defineHeadingSpec(),\n defineHeadingInput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IAAM,OAAO,EAAE,OAAO,GAAG;IAAE;GAClC;IAAE,KAAK;IAAM,OAAO,EAAE,OAAO,GAAG;IAAE;GAClC;IAAE,KAAK;IAAM,OAAO,EAAE,OAAO,GAAG;IAAE;GAClC;IAAE,KAAK;IAAM,OAAO,EAAE,OAAO,GAAG;IAAE;GAClC;IAAE,KAAK;IAAM,OAAO,EAAE,OAAO,GAAG;IAAE;GACnC;EACD,MAAM,MAAM;AACV,UAAO,CAAC,IAAI,KAAK,MAAM,SAAS,EAAE;;EAErC,CAAC;;;;;;;;ACXJ,SAAgB,gBAAkC;AAChD,QAAO,MACL,mBAAmB,EACnB,wBAAwB,EACxB,qBAAqB,EACrB,uBAAuB,CACxB"}
1
+ {"version":3,"file":"prosekit-extensions-heading.js","names":[],"sources":["../src/heading/heading-commands.ts","../src/heading/heading-input-rule.ts","../src/heading/heading-keymap.ts","../src/heading/heading-spec.ts","../src/heading/heading.ts"],"sourcesContent":["import { defineCommands, insertNode, setBlockType, toggleNode, type Extension } from '@prosekit/core'\n\nimport type { HeadingAttrs } from './heading-types'\n\n/**\n * @internal\n */\nexport type HeadingCommandsExtension = Extension<{\n Commands: {\n setHeading: [attrs?: HeadingAttrs | undefined]\n insertHeading: [attrs?: HeadingAttrs | undefined]\n toggleHeading: [attrs?: HeadingAttrs | undefined]\n }\n}>\n\n/**\n * @internal\n */\nexport function defineHeadingCommands(): HeadingCommandsExtension {\n return defineCommands({\n setHeading: (attrs?: HeadingAttrs) => {\n return setBlockType({ type: 'heading', attrs })\n },\n insertHeading: (attrs?: HeadingAttrs) => {\n return insertNode({ type: 'heading', attrs })\n },\n toggleHeading: (attrs?: HeadingAttrs) => {\n return toggleNode({ type: 'heading', attrs })\n },\n })\n}\n","import type { PlainExtension } from '@prosekit/core'\n\nimport { defineTextBlockInputRule } from '../input-rule'\n\nimport type { HeadingAttrs } from './heading-types'\n\n/**\n * Converts the text block to a heading when `#` is typed at the start of a new\n * line followed by a space.\n *\n * @internal\n */\nexport function defineHeadingInputRule(): PlainExtension {\n return defineTextBlockInputRule({\n regex: /^(#{1,6})\\s$/,\n type: 'heading',\n attrs: (match) => {\n const level: number = match[1]?.length ?? 1\n return { level } satisfies HeadingAttrs\n },\n })\n}\n","import { defineKeymap, isAtBlockStart, toggleNode, unsetBlockType, withSkipCodeBlock, type PlainExtension } from '@prosekit/core'\nimport type { Command } from '@prosekit/pm/state'\n\nfunction toggleHeadingKeybinding(level: number): Command {\n return withSkipCodeBlock(toggleNode({ type: 'heading', attrs: { level } }))\n}\n\n/**\n * Set the block type to default (usually `paragraph`) when pressing Backspace at\n * the start of a heading block.\n */\nconst backspaceUnsetHeading: Command = (state, dispatch, view) => {\n const $pos = isAtBlockStart(state, view)\n if ($pos?.parent.type.name === 'heading') {\n return unsetBlockType()(state, dispatch, view)\n }\n return false\n}\n\n/**\n * @internal\n */\nexport function defineHeadingKeymap(): PlainExtension {\n return defineKeymap({\n 'Mod-Alt-1': toggleHeadingKeybinding(1),\n 'Mod-Alt-2': toggleHeadingKeybinding(2),\n 'Mod-Alt-3': toggleHeadingKeybinding(3),\n 'Mod-Alt-4': toggleHeadingKeybinding(4),\n 'Mod-Alt-5': toggleHeadingKeybinding(5),\n 'Mod-Alt-6': toggleHeadingKeybinding(6),\n 'Backspace': backspaceUnsetHeading,\n })\n}\n","import { defineNodeSpec, type Extension } from '@prosekit/core'\n\nimport type { HeadingAttrs } from './heading-types'\n\n/**\n * @internal\n */\nexport type HeadingSpecExtension = Extension<{\n Nodes: {\n heading: HeadingAttrs\n }\n}>\n\n/**\n * @internal\n */\nexport function defineHeadingSpec(): HeadingSpecExtension {\n return defineNodeSpec({\n name: 'heading',\n attrs: { level: { default: 1, validate: 'number' } },\n content: 'inline*',\n group: 'block',\n defining: true,\n parseDOM: [\n { tag: 'h1', attrs: { level: 1 } },\n { tag: 'h2', attrs: { level: 2 } },\n { tag: 'h3', attrs: { level: 3 } },\n { tag: 'h4', attrs: { level: 4 } },\n { tag: 'h5', attrs: { level: 5 } },\n { tag: 'h6', attrs: { level: 6 } },\n ],\n toDOM(node) {\n return [`h${node.attrs.level}`, 0]\n },\n })\n}\n","import { union, type Union } from '@prosekit/core'\n\nimport { defineHeadingCommands, type HeadingCommandsExtension } from './heading-commands'\nimport { defineHeadingInputRule } from './heading-input-rule'\nimport { defineHeadingKeymap } from './heading-keymap'\nimport { defineHeadingSpec, type HeadingSpecExtension } from './heading-spec'\n\n/**\n * @internal\n */\nexport type HeadingExtension = Union<\n [HeadingSpecExtension, HeadingCommandsExtension]\n>\n\n/**\n * @public\n */\nexport function defineHeading(): HeadingExtension {\n return union(\n defineHeadingSpec(),\n defineHeadingInputRule(),\n defineHeadingKeymap(),\n defineHeadingCommands(),\n )\n}\n"],"mappings":";;;;;;;AAkBA,SAAgB,wBAAkD;AAChE,QAAO,eAAe;EACpB,aAAa,UAAyB;AACpC,UAAO,aAAa;IAAE,MAAM;IAAW;IAAO,CAAC;;EAEjD,gBAAgB,UAAyB;AACvC,UAAO,WAAW;IAAE,MAAM;IAAW;IAAO,CAAC;;EAE/C,gBAAgB,UAAyB;AACvC,UAAO,WAAW;IAAE,MAAM;IAAW;IAAO,CAAC;;EAEhD,CAAC;;;;;;;;;;;ACjBJ,SAAgB,yBAAyC;AACvD,QAAO,yBAAyB;EAC9B,OAAO;EACP,MAAM;EACN,QAAQ,UAAU;AAEhB,UAAO,EAAE,OADa,MAAM,IAAI,UAAU,GAC1B;;EAEnB,CAAC;;;;;ACjBJ,SAAS,wBAAwB,OAAwB;AACvD,QAAO,kBAAkB,WAAW;EAAE,MAAM;EAAW,OAAO,EAAE,OAAO;EAAE,CAAC,CAAC;;;;;;AAO7E,MAAM,yBAAkC,OAAO,UAAU,SAAS;AAEhE,KADa,eAAe,OAAO,KAAK,EAC9B,OAAO,KAAK,SAAS,UAC7B,QAAO,gBAAgB,CAAC,OAAO,UAAU,KAAK;AAEhD,QAAO;;;;;AAMT,SAAgB,sBAAsC;AACpD,QAAO,aAAa;EAClB,aAAa,wBAAwB,EAAE;EACvC,aAAa,wBAAwB,EAAE;EACvC,aAAa,wBAAwB,EAAE;EACvC,aAAa,wBAAwB,EAAE;EACvC,aAAa,wBAAwB,EAAE;EACvC,aAAa,wBAAwB,EAAE;EACvC,aAAa;EACd,CAAC;;;;;;;;ACfJ,SAAgB,oBAA0C;AACxD,QAAO,eAAe;EACpB,MAAM;EACN,OAAO,EAAE,OAAO;GAAE,SAAS;GAAG,UAAU;GAAU,EAAE;EACpD,SAAS;EACT,OAAO;EACP,UAAU;EACV,UAAU;GACR;IAAE,KAAK;IAAM,OAAO,EAAE,OAAO,GAAG;IAAE;GAClC;IAAE,KAAK;IAAM,OAAO,EAAE,OAAO,GAAG;IAAE;GAClC;IAAE,KAAK;IAAM,OAAO,EAAE,OAAO,GAAG;IAAE;GAClC;IAAE,KAAK;IAAM,OAAO,EAAE,OAAO,GAAG;IAAE;GAClC;IAAE,KAAK;IAAM,OAAO,EAAE,OAAO,GAAG;IAAE;GAClC;IAAE,KAAK;IAAM,OAAO,EAAE,OAAO,GAAG;IAAE;GACnC;EACD,MAAM,MAAM;AACV,UAAO,CAAC,IAAI,KAAK,MAAM,SAAS,EAAE;;EAErC,CAAC;;;;;;;;ACjBJ,SAAgB,gBAAkC;AAChD,QAAO,MACL,mBAAmB,EACnB,wBAAwB,EACxB,qBAAqB,EACrB,uBAAuB,CACxB"}
@@ -1 +1 @@
1
- {"version":3,"file":"prosekit-extensions-horizontal-rule.d.ts","names":[],"sources":["../src/horizontal-rule/horizontal-rule-commands.ts","../src/horizontal-rule/horizontal-rule-spec.ts","../src/horizontal-rule/horizontal-rule.ts","../src/horizontal-rule/horizontal-rule-input-rule.ts"],"sourcesContent":[],"mappings":";;;;;KAWY,+BAAA,GAAkC;;;EAAlC,CAAA;AASZ,CAAA,CAAA;AAcA;;;iBAdgB,oBAAA,CAAA,GAAwB;ACd5B,iBD4BI,4BAAA,CAAA,CC5B0B,ED4BM,+BC5BG;;;KAAvC,2BAAA,GAA8B;;oBAEtB;EDGR,CAAA;AASZ,CAAA,CAAA;AAcgB,iBCtBA,wBAAA,CAAA,CDsBgC,ECtBJ,2BDsBI;;;KEnBpC,uBAAA,GAA0B,OACnC,6BAA6B,+BFLpB,CASZ,CAAA;AAcA;;;iBEZgB,oBAAA,CAAA,GAAwB;;;;;;iBCVxB,6BAAA,CAAA,GAAiC"}
1
+ {"version":3,"file":"prosekit-extensions-horizontal-rule.d.ts","names":[],"sources":["../src/horizontal-rule/horizontal-rule-commands.ts","../src/horizontal-rule/horizontal-rule-spec.ts","../src/horizontal-rule/horizontal-rule.ts","../src/horizontal-rule/horizontal-rule-input-rule.ts"],"mappings":";;;;;KAIY,+BAAA,GAAkC,SAAA;EAC5C,QAAA;IACE,oBAAA;EAAA;AAAA;;;;iBAOY,oBAAA,CAAA,GAAwB,OAAA;AAAA,iBAcxB,4BAAA,CAAA,GAAgC,+BAAA;;;KCxBpC,2BAAA,GAA8B,SAAA;EACxC,KAAA;IACE,cAAA,EAAgB,KAAA;EAAA;AAAA;AAAA,iBAIJ,wBAAA,CAAA,GAA4B,2BAAA;;;KCHhC,uBAAA,GAA0B,KAAA,EACnC,2BAAA,EAA6B,+BAAA;;;;iBAMhB,oBAAA,CAAA,GAAwB,uBAAA;;;;;;iBCLxB,6BAAA,CAAA,GAAiC,cAAA"}
@@ -1,4 +1,4 @@
1
- import { n as defineInputRule } from "./input-rule-dmsb3j6w.js";
1
+ import { n as defineInputRule } from "./input-rule-COGr_GBb.js";
2
2
  import { defineCommands, defineNodeSpec, getNodeType, union } from "@prosekit/core";
3
3
  import { InputRule } from "@prosekit/pm/inputrules";
4
4
  import { Fragment, Slice } from "@prosekit/pm/model";
@@ -1 +1 @@
1
- {"version":3,"file":"prosekit-extensions-horizontal-rule.js","names":[],"sources":["../src/horizontal-rule/horizontal-rule-commands.ts","../src/horizontal-rule/horizontal-rule-input-rule.ts","../src/horizontal-rule/horizontal-rule-spec.ts","../src/horizontal-rule/horizontal-rule.ts"],"sourcesContent":["import {\n defineCommands,\n getNodeType,\n type Extension,\n} from '@prosekit/core'\nimport {\n Fragment,\n Slice,\n} from '@prosekit/pm/model'\nimport type { Command } from '@prosekit/pm/state'\n\nexport type HorizontalRuleCommandsExtension = Extension<{\n Commands: {\n insertHorizontalRule: []\n }\n}>\n\n/**\n * Returns a command that inserts a horizontal rule at the current selection.\n */\nexport function insertHorizontalRule(): Command {\n return (state, dispatch) => {\n if (!dispatch) return true\n\n const { schema, tr } = state\n const type = getNodeType(schema, 'horizontalRule')\n const node = type.createChecked()\n const pos = tr.selection.anchor\n tr.replaceRange(pos, pos, new Slice(Fragment.from(node), 0, 0))\n dispatch(tr)\n return true\n }\n}\n\nexport function defineHorizontalRuleCommands(): HorizontalRuleCommandsExtension {\n return defineCommands({ insertHorizontalRule })\n}\n","import {\n getNodeType,\n union,\n type PlainExtension,\n} from '@prosekit/core'\nimport { InputRule } from '@prosekit/pm/inputrules'\n\nimport { defineInputRule } from '../input-rule'\n\n/**\n * @public\n */\nexport function defineHorizontalRuleInputRule(): PlainExtension {\n return union(\n defineInputRule(\n new InputRule(/^---$/, (state, match, start, end) => {\n const { schema } = state\n const { tr } = state\n const type = getNodeType(schema, 'horizontalRule')\n const node = type.createChecked()\n tr.delete(start, end).insert(start - 1, node)\n return tr.scrollIntoView()\n }),\n ),\n )\n}\n","import {\n defineNodeSpec,\n type Extension,\n} from '@prosekit/core'\nimport type { Attrs } from '@prosekit/pm/model'\n\nexport type HorizontalRuleSpecExtension = Extension<{\n Nodes: {\n horizontalRule: Attrs\n }\n}>\n\nexport function defineHorizontalRuleSpec(): HorizontalRuleSpecExtension {\n return defineNodeSpec({\n name: 'horizontalRule',\n group: 'block',\n parseDOM: [{ tag: 'hr' }],\n // Wrap the `<hr>` in a `<div>` so that we can make it taller and easier to click.\n toDOM: () => ['div', { class: 'prosekit-horizontal-rule' }, ['hr']],\n })\n}\n","import {\n union,\n type Union,\n} from '@prosekit/core'\n\nimport {\n defineHorizontalRuleCommands,\n type HorizontalRuleCommandsExtension,\n} from './horizontal-rule-commands'\nimport { defineHorizontalRuleInputRule } from './horizontal-rule-input-rule'\nimport {\n defineHorizontalRuleSpec,\n type HorizontalRuleSpecExtension,\n} from './horizontal-rule-spec'\n\nexport type HorizontalRuleExtension = Union<\n [HorizontalRuleSpecExtension, HorizontalRuleCommandsExtension]\n>\n\n/**\n * @public\n */\nexport function defineHorizontalRule(): HorizontalRuleExtension {\n return union(\n defineHorizontalRuleSpec(),\n defineHorizontalRuleInputRule(),\n defineHorizontalRuleCommands(),\n )\n}\n"],"mappings":";;;;;;;;;AAoBA,SAAgB,uBAAgC;AAC9C,SAAQ,OAAO,aAAa;AAC1B,MAAI,CAAC,SAAU,QAAO;EAEtB,MAAM,EAAE,QAAQ,OAAO;EAEvB,MAAM,OADO,YAAY,QAAQ,iBAAiB,CAChC,eAAe;EACjC,MAAM,MAAM,GAAG,UAAU;AACzB,KAAG,aAAa,KAAK,KAAK,IAAI,MAAM,SAAS,KAAK,KAAK,EAAE,GAAG,EAAE,CAAC;AAC/D,WAAS,GAAG;AACZ,SAAO;;;AAIX,SAAgB,+BAAgE;AAC9E,QAAO,eAAe,EAAE,sBAAsB,CAAC;;;;;;;;ACvBjD,SAAgB,gCAAgD;AAC9D,QAAO,MACL,gBACE,IAAI,UAAU,UAAU,OAAO,OAAO,OAAO,QAAQ;EACnD,MAAM,EAAE,WAAW;EACnB,MAAM,EAAE,OAAO;EAEf,MAAM,OADO,YAAY,QAAQ,iBAAiB,CAChC,eAAe;AACjC,KAAG,OAAO,OAAO,IAAI,CAAC,OAAO,QAAQ,GAAG,KAAK;AAC7C,SAAO,GAAG,gBAAgB;GAC1B,CACH,CACF;;;;;ACZH,SAAgB,2BAAwD;AACtE,QAAO,eAAe;EACpB,MAAM;EACN,OAAO;EACP,UAAU,CAAC,EAAE,KAAK,MAAM,CAAC;EAEzB,aAAa;GAAC;GAAO,EAAE,OAAO,4BAA4B;GAAE,CAAC,KAAK;GAAC;EACpE,CAAC;;;;;;;;ACGJ,SAAgB,uBAAgD;AAC9D,QAAO,MACL,0BAA0B,EAC1B,+BAA+B,EAC/B,8BAA8B,CAC/B"}
1
+ {"version":3,"file":"prosekit-extensions-horizontal-rule.js","names":[],"sources":["../src/horizontal-rule/horizontal-rule-commands.ts","../src/horizontal-rule/horizontal-rule-input-rule.ts","../src/horizontal-rule/horizontal-rule-spec.ts","../src/horizontal-rule/horizontal-rule.ts"],"sourcesContent":["import { defineCommands, getNodeType, type Extension } from '@prosekit/core'\nimport { Fragment, Slice } from '@prosekit/pm/model'\nimport type { Command } from '@prosekit/pm/state'\n\nexport type HorizontalRuleCommandsExtension = Extension<{\n Commands: {\n insertHorizontalRule: []\n }\n}>\n\n/**\n * Returns a command that inserts a horizontal rule at the current selection.\n */\nexport function insertHorizontalRule(): Command {\n return (state, dispatch) => {\n if (!dispatch) return true\n\n const { schema, tr } = state\n const type = getNodeType(schema, 'horizontalRule')\n const node = type.createChecked()\n const pos = tr.selection.anchor\n tr.replaceRange(pos, pos, new Slice(Fragment.from(node), 0, 0))\n dispatch(tr)\n return true\n }\n}\n\nexport function defineHorizontalRuleCommands(): HorizontalRuleCommandsExtension {\n return defineCommands({ insertHorizontalRule })\n}\n","import { getNodeType, union, type PlainExtension } from '@prosekit/core'\nimport { InputRule } from '@prosekit/pm/inputrules'\n\nimport { defineInputRule } from '../input-rule'\n\n/**\n * @public\n */\nexport function defineHorizontalRuleInputRule(): PlainExtension {\n return union(\n defineInputRule(\n new InputRule(/^---$/, (state, match, start, end) => {\n const { schema } = state\n const { tr } = state\n const type = getNodeType(schema, 'horizontalRule')\n const node = type.createChecked()\n tr.delete(start, end).insert(start - 1, node)\n return tr.scrollIntoView()\n }),\n ),\n )\n}\n","import { defineNodeSpec, type Extension } from '@prosekit/core'\nimport type { Attrs } from '@prosekit/pm/model'\n\nexport type HorizontalRuleSpecExtension = Extension<{\n Nodes: {\n horizontalRule: Attrs\n }\n}>\n\nexport function defineHorizontalRuleSpec(): HorizontalRuleSpecExtension {\n return defineNodeSpec({\n name: 'horizontalRule',\n group: 'block',\n parseDOM: [{ tag: 'hr' }],\n // Wrap the `<hr>` in a `<div>` so that we can make it taller and easier to click.\n toDOM: () => ['div', { class: 'prosekit-horizontal-rule' }, ['hr']],\n })\n}\n","import { union, type Union } from '@prosekit/core'\n\nimport { defineHorizontalRuleCommands, type HorizontalRuleCommandsExtension } from './horizontal-rule-commands'\nimport { defineHorizontalRuleInputRule } from './horizontal-rule-input-rule'\nimport { defineHorizontalRuleSpec, type HorizontalRuleSpecExtension } from './horizontal-rule-spec'\n\nexport type HorizontalRuleExtension = Union<\n [HorizontalRuleSpecExtension, HorizontalRuleCommandsExtension]\n>\n\n/**\n * @public\n */\nexport function defineHorizontalRule(): HorizontalRuleExtension {\n return union(\n defineHorizontalRuleSpec(),\n defineHorizontalRuleInputRule(),\n defineHorizontalRuleCommands(),\n )\n}\n"],"mappings":";;;;;;;;;AAaA,SAAgB,uBAAgC;AAC9C,SAAQ,OAAO,aAAa;AAC1B,MAAI,CAAC,SAAU,QAAO;EAEtB,MAAM,EAAE,QAAQ,OAAO;EAEvB,MAAM,OADO,YAAY,QAAQ,iBAAiB,CAChC,eAAe;EACjC,MAAM,MAAM,GAAG,UAAU;AACzB,KAAG,aAAa,KAAK,KAAK,IAAI,MAAM,SAAS,KAAK,KAAK,EAAE,GAAG,EAAE,CAAC;AAC/D,WAAS,GAAG;AACZ,SAAO;;;AAIX,SAAgB,+BAAgE;AAC9E,QAAO,eAAe,EAAE,sBAAsB,CAAC;;;;;;;;ACpBjD,SAAgB,gCAAgD;AAC9D,QAAO,MACL,gBACE,IAAI,UAAU,UAAU,OAAO,OAAO,OAAO,QAAQ;EACnD,MAAM,EAAE,WAAW;EACnB,MAAM,EAAE,OAAO;EAEf,MAAM,OADO,YAAY,QAAQ,iBAAiB,CAChC,eAAe;AACjC,KAAG,OAAO,OAAO,IAAI,CAAC,OAAO,QAAQ,GAAG,KAAK;AAC7C,SAAO,GAAG,gBAAgB;GAC1B,CACH,CACF;;;;;ACXH,SAAgB,2BAAwD;AACtE,QAAO,eAAe;EACpB,MAAM;EACN,OAAO;EACP,UAAU,CAAC,EAAE,KAAK,MAAM,CAAC;EAEzB,aAAa;GAAC;GAAO,EAAE,OAAO,4BAA4B;GAAE,CAAC,KAAK;GAAC;EACpE,CAAC;;;;;;;;ACHJ,SAAgB,uBAAgD;AAC9D,QAAO,MACL,0BAA0B,EAC1B,+BAA+B,EAC/B,8BAA8B,CAC/B"}
@@ -1,10 +1,9 @@
1
- import { l as FileDropHandlerOptions, n as UploadTask, o as FilePasteHandlerOptions, r as Uploader } from "./index-oIc1a2f2.js";
1
+ import { l as FileDropHandlerOptions, n as UploadTask, o as FilePasteHandlerOptions, r as Uploader } from "./index-cp1u4e0e.js";
2
2
  import { Extension, PlainExtension, Union } from "@prosekit/core";
3
3
  import { Command } from "@prosekit/pm/state";
4
4
  import { EditorView } from "@prosekit/pm/view";
5
5
 
6
6
  //#region src/image/image-commands/upload-image.d.ts
7
-
8
7
  /**
9
8
  * Options for {@link uploadImage}.
10
9
  *
@@ -25,6 +24,13 @@ interface UploadImageOptions {
25
24
  * image is inserted at the current selection.
26
25
  */
27
26
  pos?: number;
27
+ /**
28
+ * If the image should replace the existing image at the given position. This
29
+ * is only used if `pos` is provided.
30
+ *
31
+ * @default false
32
+ */
33
+ replace?: boolean;
28
34
  /**
29
35
  * A handler to be called when an error occurs during the upload.
30
36
  */
@@ -67,6 +73,7 @@ declare function uploadImage({
67
73
  uploader,
68
74
  file,
69
75
  pos,
76
+ replace,
70
77
  onError
71
78
  }: UploadImageOptions): Command;
72
79
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"prosekit-extensions-image.d.ts","names":[],"sources":["../src/image/image-commands/upload-image.ts","../src/image/image-spec.ts","../src/image/image-commands.ts","../src/image/image.ts","../src/image/image-commands/insert-image.ts","../src/image/image-upload-handler.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;AAkBA;;AASQ,U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AiB,KHCM,CAAA,CGDC,kBHCD,EGDqB,sBHCrB,CAAA,CAAA;;;;AAkBA,iBGdnB,WAAA,CAAA,CHcmB,EGdJ,cHcI;;;;;;;AAlBnC;;AASQ,iBIhBQ,WAAA,CJgBR,KAAA,CAAA,EIhB4B,UJgB5B,CAAA,EIhByC,OJgBzC;;;;;;AATS,KKKL,sBAAA,GLLuB,CAAA,OAAA,EKKY,uBLLZ,EAAA,GAAA,OAAA;;;;AAkBA,KKRvB,qBAAA,GLQuB,CAAA,OAAA,EKRW,sBLQX,EAAA,GAAA,OAAA;AAQnC;AAoBA;AAUA;AAA8B,UKzCb,yBAAA,CLyCa;EAAU;;;;EAA2C,QAAA,EKpCvE,QLoCuE,CAAA,MAAA,CAAA;EAAO;AAsC1F;;;aKrEa;EJnCI;AASjB;AASA;;YIsBY;;AHjCZ;;;EAAqC,OAAA,CAAA,EGsCzB,uBHtCyB;;AAUrC;;;;ACRA;;AAAwD,iBEsDxC,wBAAA,CFtDwC;EAAA,QAAA;EAAA,QAAA;EAAA,OAAA;EAAA;AAAA,CAAA,EE2DrD,yBF3DqD,CAAA,EE2DzB,cF3DyB"}
1
+ {"version":3,"file":"prosekit-extensions-image.d.ts","names":[],"sources":["../src/image/image-commands/upload-image.ts","../src/image/image-spec.ts","../src/image/image-commands.ts","../src/image/image.ts","../src/image/image-commands/insert-image.ts","../src/image/image-upload-handler.ts"],"mappings":";;;;;;;;;AAYA;;UAAiB,kBAAA;EAKL;;;;EAAV,QAAA,EAAU,QAAA;EAAV;;;EAIA,IAAA,EAAM,IAAA;EAKN;;;;EAAA,GAAA;EAWiC;AAQnC;;;;;EAZE,OAAA;EAoBA;;;EAhBA,OAAA,GAAU,uBAAA;AAAA;AA4BZ;;;;;AAAA,UApBiB,8BAAA;EA8BU;;;EA1BzB,IAAA,EAAM,IAAA;EA6BN;;;EAzBA,KAAA;EA4BsB;;;EAxBtB,UAAA,EAAY,UAAA;AAAA;;;;;;KAQF,uBAAA,IAA2B,OAAA,EAAS,8BAAA;;;;;;;AAkFhD;;iBAxEgB,WAAA,CAAA;EACd,QAAA;EACA,IAAA;EACA,GAAA;EACA,OAAA;EACA;AAAA,GACC,kBAAA,GAAqB,OAAA;;;;;;iBAkER,eAAA,CACd,IAAA,EAAM,UAAA,EACN,MAAA,UACA,MAAA;;;;;;UCjJe,UAAA;EACf,GAAA;EACA,KAAA;EACA,MAAA;AAAA;;;;KAMU,kBAAA,GAAqB,SAAA;EAC/B,KAAA;IACE,KAAA,EAAO,UAAA;EAAA;AAAA;;;;iBAOK,eAAA,CAAA,GAAmB,kBAAA;;;;;;KCdvB,sBAAA,GAAyB,SAAA;EACnC,QAAA;IACE,WAAA,GAAc,KAAA,GAAQ,UAAA;IACtB,WAAA,GAAc,OAAA,EAAS,kBAAA;EAAA;AAAA;;;;iBAOX,mBAAA,CAAA,GAAuB,sBAAA;;;;;;KCX3B,cAAA,GAAiB,KAAA,EAAO,kBAAA,EAAoB,sBAAA;;;;iBAKxC,WAAA,CAAA,GAAe,cAAA;;;;;;;AHD/B;;iBIDgB,WAAA,CAAY,KAAA,GAAQ,UAAA,GAAa,OAAA;;;;;;KCMrC,sBAAA,IAA0B,OAAA,EAAS,uBAAA;;;;KAKnC,qBAAA,IAAyB,OAAA,EAAS,sBAAA;;;;UAK7B,yBAAA;ELVL;;;;EKeV,QAAA,EAAU,QAAA;ELKV;;;;EKAA,QAAA,GAAW,sBAAA;ELQkC;;;;EKH7C,OAAA,GAAU,qBAAA;ELWV;;;;EKNA,OAAA,GAAU,uBAAA;AAAA;;;;;AL4BZ;;iBKVgB,wBAAA,CAAA;EACd,QAAA;EACA,QAAA;EACA,OAAA;EACA;AAAA,GACC,yBAAA,GAA4B,cAAA"}
@@ -1,4 +1,4 @@
1
- import { n as defineFilePasteHandler, r as defineFileDropHandler, t as UploadTask } from "./file-DrfcSid-.js";
1
+ import { n as defineFilePasteHandler, r as defineFileDropHandler, t as UploadTask } from "./file-iLVR0eM0.js";
2
2
  import { ProseKitError, defineCommands, defineNodeSpec, insertNode, union } from "@prosekit/core";
3
3
 
4
4
  //#region src/image/image-commands/insert-image.ts
@@ -25,14 +25,13 @@ function insertImage(attrs) {
25
25
  *
26
26
  * @public
27
27
  */
28
- function uploadImage({ uploader, file, pos, onError }) {
28
+ function uploadImage({ uploader, file, pos, replace = false, onError }) {
29
29
  return (state, dispatch, view) => {
30
30
  const uploadTask = new UploadTask({
31
31
  file,
32
32
  uploader
33
33
  });
34
34
  const objectURL = uploadTask.objectURL;
35
- const attrs = { src: objectURL };
36
35
  uploadTask.finished.then((resultURL) => {
37
36
  if (view && view.isDestroyed) return;
38
37
  else if (typeof resultURL !== "string") {
@@ -60,13 +59,27 @@ function uploadImage({ uploader, file, pos, onError }) {
60
59
  uploadTask
61
60
  });
62
61
  });
62
+ if (replace && pos != null) {
63
+ if (replaceExistingImageURL(state, pos, objectURL, dispatch)) return true;
64
+ }
63
65
  return insertNode({
64
66
  type: "image",
65
- attrs,
67
+ attrs: { src: objectURL },
66
68
  pos
67
69
  })(state, dispatch, view);
68
70
  };
69
71
  }
72
+ function replaceExistingImageURL(state, pos, imageURL, dispatch) {
73
+ const node = state.doc.nodeAt(pos);
74
+ if (!node || node.type.name !== "image") return false;
75
+ if (node.attrs.src === imageURL) return true;
76
+ if (dispatch) {
77
+ const tr = state.tr;
78
+ tr.setNodeAttribute(pos, "src", imageURL);
79
+ dispatch(tr);
80
+ }
81
+ return true;
82
+ }
70
83
  /**
71
84
  * Replaces the temporary image URL with the final uploaded URL.
72
85
  *