@prosekit/extensions 0.14.0 → 0.14.2

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 (248) hide show
  1. package/dist/{drop-indicator-B_oMfeVP.js → drop-indicator-DJq8pF92.js} +1 -1
  2. package/dist/{drop-indicator-B_oMfeVP.js.map → drop-indicator-DJq8pF92.js.map} +1 -1
  3. package/dist/{file-iLVR0eM0.js → file-upload-I9m1EJAM.js} +1 -1
  4. package/dist/file-upload-I9m1EJAM.js.map +1 -0
  5. package/dist/{index-cp1u4e0e.d.ts → file-upload-dr3IXUty.d.ts} +1 -1
  6. package/dist/file-upload-dr3IXUty.d.ts.map +1 -0
  7. package/dist/{paste-rule-BaDghcaU.js → mark-paste-rule--F1QPUcU.js} +2 -2
  8. package/dist/mark-paste-rule--F1QPUcU.js.map +1 -0
  9. package/dist/{mark-rule-CYe8zk4q.js → mark-rule-Bqdm49Eq.js} +2 -2
  10. package/dist/mark-rule-Bqdm49Eq.js.map +1 -0
  11. package/dist/prosekit-extensions-autocomplete.d.ts +1 -1
  12. package/dist/prosekit-extensions-autocomplete.js +17 -17
  13. package/dist/prosekit-extensions-autocomplete.js.map +1 -1
  14. package/dist/prosekit-extensions-background-color.d.ts +1 -1
  15. package/dist/prosekit-extensions-background-color.js.map +1 -1
  16. package/dist/prosekit-extensions-blockquote.d.ts +13 -13
  17. package/dist/prosekit-extensions-blockquote.d.ts.map +1 -1
  18. package/dist/prosekit-extensions-blockquote.js +6 -5
  19. package/dist/prosekit-extensions-blockquote.js.map +1 -1
  20. package/dist/prosekit-extensions-bold.d.ts +12 -12
  21. package/dist/prosekit-extensions-bold.d.ts.map +1 -1
  22. package/dist/prosekit-extensions-bold.js +1 -1
  23. package/dist/prosekit-extensions-bold.js.map +1 -1
  24. package/dist/prosekit-extensions-code-block.d.ts +53 -36
  25. package/dist/prosekit-extensions-code-block.d.ts.map +1 -1
  26. package/dist/prosekit-extensions-code-block.js +78 -72
  27. package/dist/prosekit-extensions-code-block.js.map +1 -1
  28. package/dist/prosekit-extensions-code.d.ts +12 -12
  29. package/dist/prosekit-extensions-code.d.ts.map +1 -1
  30. package/dist/prosekit-extensions-code.js +1 -1
  31. package/dist/prosekit-extensions-code.js.map +1 -1
  32. package/dist/prosekit-extensions-commit.d.ts +1 -1
  33. package/dist/prosekit-extensions-commit.js +1 -1
  34. package/dist/prosekit-extensions-drop-indicator.js +1 -1
  35. package/dist/prosekit-extensions-enter-rule.d.ts +6 -78
  36. package/dist/prosekit-extensions-enter-rule.d.ts.map +1 -1
  37. package/dist/prosekit-extensions-enter-rule.js +37 -2
  38. package/dist/prosekit-extensions-enter-rule.js.map +1 -0
  39. package/dist/prosekit-extensions-file.d.ts +2 -2
  40. package/dist/prosekit-extensions-file.js +1 -1
  41. package/dist/prosekit-extensions-hard-break.d.ts +7 -7
  42. package/dist/prosekit-extensions-hard-break.d.ts.map +1 -1
  43. package/dist/prosekit-extensions-hard-break.js.map +1 -1
  44. package/dist/prosekit-extensions-heading.d.ts +15 -15
  45. package/dist/prosekit-extensions-heading.d.ts.map +1 -1
  46. package/dist/prosekit-extensions-heading.js +1 -1
  47. package/dist/prosekit-extensions-heading.js.map +1 -1
  48. package/dist/prosekit-extensions-horizontal-rule.d.ts +7 -7
  49. package/dist/prosekit-extensions-horizontal-rule.d.ts.map +1 -1
  50. package/dist/prosekit-extensions-horizontal-rule.js +11 -10
  51. package/dist/prosekit-extensions-horizontal-rule.js.map +1 -1
  52. package/dist/prosekit-extensions-image.d.ts +13 -12
  53. package/dist/prosekit-extensions-image.d.ts.map +1 -1
  54. package/dist/prosekit-extensions-image.js +10 -10
  55. package/dist/prosekit-extensions-image.js.map +1 -1
  56. package/dist/prosekit-extensions-input-rule.js +89 -2
  57. package/dist/prosekit-extensions-input-rule.js.map +1 -0
  58. package/dist/prosekit-extensions-italic.d.ts +12 -12
  59. package/dist/prosekit-extensions-italic.d.ts.map +1 -1
  60. package/dist/prosekit-extensions-italic.js +1 -1
  61. package/dist/prosekit-extensions-italic.js.map +1 -1
  62. package/dist/prosekit-extensions-link.js +4 -4
  63. package/dist/prosekit-extensions-link.js.map +1 -1
  64. package/dist/prosekit-extensions-list.d.ts +26 -26
  65. package/dist/prosekit-extensions-list.d.ts.map +1 -1
  66. package/dist/prosekit-extensions-list.js +27 -27
  67. package/dist/prosekit-extensions-list.js.map +1 -1
  68. package/dist/prosekit-extensions-loro.d.ts +16 -16
  69. package/dist/prosekit-extensions-loro.d.ts.map +1 -1
  70. package/dist/prosekit-extensions-loro.js.map +1 -1
  71. package/dist/prosekit-extensions-mark-rule.js +1 -1
  72. package/dist/prosekit-extensions-math.d.ts +154 -0
  73. package/dist/prosekit-extensions-math.d.ts.map +1 -0
  74. package/dist/prosekit-extensions-math.js +108 -0
  75. package/dist/prosekit-extensions-math.js.map +1 -0
  76. package/dist/prosekit-extensions-mod-click-prevention.js +1 -1
  77. package/dist/prosekit-extensions-paragraph.d.ts +7 -7
  78. package/dist/prosekit-extensions-paragraph.d.ts.map +1 -1
  79. package/dist/prosekit-extensions-paragraph.js.map +1 -1
  80. package/dist/prosekit-extensions-paste-rule.js +1 -1
  81. package/dist/prosekit-extensions-placeholder.d.ts +1 -1
  82. package/dist/prosekit-extensions-placeholder.js +2 -2
  83. package/dist/prosekit-extensions-placeholder.js.map +1 -1
  84. package/dist/prosekit-extensions-readonly.js +1 -1
  85. package/dist/prosekit-extensions-strike.js +1 -1
  86. package/dist/prosekit-extensions-strike.js.map +1 -1
  87. package/dist/prosekit-extensions-table.d.ts +47 -47
  88. package/dist/prosekit-extensions-table.d.ts.map +1 -1
  89. package/dist/prosekit-extensions-table.js +1 -1
  90. package/dist/prosekit-extensions-text-align.d.ts +1 -1
  91. package/dist/prosekit-extensions-text-color.d.ts +1 -1
  92. package/dist/prosekit-extensions-text-color.js.map +1 -1
  93. package/dist/prosekit-extensions-virtual-selection.js +1 -1
  94. package/dist/prosekit-extensions-yjs.d.ts +3 -3
  95. package/dist/prosekit-extensions-yjs.d.ts.map +1 -1
  96. package/dist/prosekit-extensions-yjs.js.map +1 -1
  97. package/dist/shiki-highlighter-chunk.d.ts +19 -2
  98. package/dist/shiki-highlighter-chunk.d.ts.map +1 -0
  99. package/dist/{table-4oHfV-Ql.js → table-B81i9oH9.js} +29 -29
  100. package/dist/table-B81i9oH9.js.map +1 -0
  101. package/package.json +22 -10
  102. package/src/autocomplete/autocomplete-helpers.ts +1 -1
  103. package/src/autocomplete/autocomplete-plugin.ts +2 -2
  104. package/src/autocomplete/autocomplete-rule.ts +1 -1
  105. package/src/autocomplete/autocomplete.spec.ts +4 -4
  106. package/src/autocomplete/autocomplete.ts +2 -2
  107. package/src/autocomplete/index.ts +2 -2
  108. package/src/background-color/background-color-commands.spec.ts +1 -1
  109. package/src/background-color/background-color-commands.ts +1 -1
  110. package/src/background-color/background-color-spec.spec.ts +1 -1
  111. package/src/background-color/background-color.ts +2 -2
  112. package/src/background-color/index.ts +3 -3
  113. package/src/blockquote/blockquote-input-rule.ts +1 -1
  114. package/src/blockquote/blockquote-keymap.spec.ts +1 -1
  115. package/src/blockquote/blockquote-keymap.ts +9 -7
  116. package/src/blockquote/blockquote.ts +4 -4
  117. package/src/blockquote/index.ts +5 -5
  118. package/src/bold/bold-input-rule.spec.ts +2 -2
  119. package/src/bold/bold-input-rule.ts +1 -1
  120. package/src/bold/bold.ts +4 -4
  121. package/src/bold/index.ts +5 -5
  122. package/src/code/code-input-rule.ts +1 -1
  123. package/src/code/code.ts +4 -4
  124. package/src/code/index.ts +5 -5
  125. package/src/code-block/code-block-commands.ts +1 -1
  126. package/src/code-block/code-block-highlight.ts +11 -1
  127. package/src/code-block/code-block-input-rule.ts +3 -3
  128. package/src/code-block/code-block-shiki.ts +13 -5
  129. package/src/code-block/code-block-spec.spec.ts +2 -2
  130. package/src/code-block/code-block-spec.ts +1 -1
  131. package/src/code-block/code-block.ts +4 -4
  132. package/src/code-block/index.ts +9 -9
  133. package/src/code-block/shiki-highlighter.ts +2 -2
  134. package/src/code-block/shiki-parser.ts +2 -2
  135. package/src/drop-cursor/index.ts +1 -1
  136. package/src/drop-indicator/drop-indicator.ts +1 -1
  137. package/src/drop-indicator/index.ts +1 -1
  138. package/src/enter-rule/index.ts +18 -191
  139. package/src/file/file-drop-handler.ts +1 -1
  140. package/src/file/file-paste-handler.spec.ts +3 -3
  141. package/src/file/file-paste-handler.ts +1 -1
  142. package/src/file/index.ts +3 -3
  143. package/src/gap-cursor/index.ts +1 -1
  144. package/src/hard-break/hard-break-keymap.spec.ts +2 -2
  145. package/src/hard-break/hard-break-keymap.ts +1 -1
  146. package/src/hard-break/hard-break.ts +3 -3
  147. package/src/hard-break/index.ts +4 -4
  148. package/src/heading/heading-commands.ts +1 -1
  149. package/src/heading/heading-input-rule.ts +2 -2
  150. package/src/heading/heading-keymap.spec.ts +1 -1
  151. package/src/heading/heading-spec.ts +1 -1
  152. package/src/heading/heading.ts +4 -4
  153. package/src/heading/index.ts +6 -6
  154. package/src/horizontal-rule/horizontal-rule-commands.spec.ts +1 -1
  155. package/src/horizontal-rule/horizontal-rule-commands.ts +13 -11
  156. package/src/horizontal-rule/horizontal-rule-input-rule.spec.ts +2 -2
  157. package/src/horizontal-rule/horizontal-rule-input-rule.ts +1 -1
  158. package/src/horizontal-rule/horizontal-rule.ts +3 -3
  159. package/src/horizontal-rule/index.ts +4 -4
  160. package/src/image/image-commands/insert-image.ts +1 -1
  161. package/src/image/image-commands/upload-image.spec.ts +4 -4
  162. package/src/image/image-commands/upload-image.ts +2 -2
  163. package/src/image/image-commands.ts +3 -3
  164. package/src/image/image-upload-handler.ts +2 -2
  165. package/src/image/image.ts +2 -2
  166. package/src/image/index.ts +6 -6
  167. package/src/italic/index.ts +5 -5
  168. package/src/italic/italic-commands.spec.ts +4 -4
  169. package/src/italic/italic-input-rule.spec.ts +2 -2
  170. package/src/italic/italic-input-rule.ts +1 -1
  171. package/src/italic/italic.ts +4 -4
  172. package/src/link/index.spec.ts +2 -2
  173. package/src/link/index.ts +6 -6
  174. package/src/link/link-paste-rule.spec.ts +2 -2
  175. package/src/link/link-paste-rule.ts +3 -3
  176. package/src/link/link-regex.spec.ts +1 -1
  177. package/src/list/index.ts +8 -8
  178. package/src/list/list-drop-indicator.ts +2 -2
  179. package/src/list/list-input-rules.ts +1 -1
  180. package/src/list/list-keymap.spec.ts +1 -1
  181. package/src/list/list-spec.ts +1 -1
  182. package/src/list/list-types.spec.ts +2 -2
  183. package/src/list/list.spec.ts +6 -6
  184. package/src/list/list.ts +7 -7
  185. package/src/loro/index.ts +6 -6
  186. package/src/loro/loro.ts +5 -5
  187. package/src/mark-rule/apply.ts +2 -2
  188. package/src/mark-rule/index.ts +2 -2
  189. package/src/mark-rule/mark-rule.spec.ts +4 -4
  190. package/src/mark-rule/mark-rule.ts +2 -2
  191. package/src/math/index.ts +22 -0
  192. package/src/math/math-block.ts +96 -0
  193. package/src/math/math-inline.ts +89 -0
  194. package/src/math/math-plugin.ts +8 -0
  195. package/src/math/math.ts +39 -0
  196. package/src/paragraph/index.ts +7 -7
  197. package/src/paragraph/paragraph-keymap.ts +1 -1
  198. package/src/paragraph/paragraph.ts +3 -3
  199. package/src/paste-rule/index.ts +2 -2
  200. package/src/paste-rule/mark-paste-rule.spec.ts +8 -8
  201. package/src/paste-rule/mark-paste-rule.ts +2 -2
  202. package/src/paste-rule/paste-rule.spec.ts +2 -2
  203. package/src/paste-rule/paste-rule.ts +1 -1
  204. package/src/paste-rule/split-text-by-regex.spec.ts +1 -1
  205. package/src/placeholder/index.ts +1 -1
  206. package/src/strike/index.ts +1 -1
  207. package/src/table/index.ts +14 -14
  208. package/src/table/table-commands/delete-cell-selection.spec.ts +3 -3
  209. package/src/table/table-commands/exit-table.spec.ts +2 -2
  210. package/src/table/table-commands/insert-table.spec.ts +1 -1
  211. package/src/table/table-commands/move-table-column.spec.ts +2 -2
  212. package/src/table/table-commands/move-table-row.spec.ts +2 -2
  213. package/src/table/table-commands/select-table-cell.spec.ts +3 -3
  214. package/src/table/table-commands/select-table-cell.ts +1 -1
  215. package/src/table/table-commands/select-table-column.spec.ts +2 -2
  216. package/src/table/table-commands/select-table-column.ts +1 -1
  217. package/src/table/table-commands/select-table-row.spec.ts +2 -2
  218. package/src/table/table-commands/select-table-row.ts +1 -1
  219. package/src/table/table-commands/select-table.spec.ts +2 -2
  220. package/src/table/table-commands/select-table.ts +1 -1
  221. package/src/table/table-commands.ts +9 -9
  222. package/src/table/table-drop-indicator.ts +2 -2
  223. package/src/table/table-spec.spec.ts +4 -4
  224. package/src/table/table.ts +4 -4
  225. package/src/table/test-utils.ts +1 -1
  226. package/src/testing/index.ts +25 -22
  227. package/src/testing/katex.ts +9 -0
  228. package/src/text-color/index.ts +3 -3
  229. package/src/text-color/text-color-commands.spec.ts +1 -1
  230. package/src/text-color/text-color-commands.ts +1 -1
  231. package/src/text-color/text-color-spec.spec.ts +1 -1
  232. package/src/text-color/text-color.ts +2 -2
  233. package/src/yjs/index.ts +7 -7
  234. package/src/yjs/yjs-cursor-plugin.ts +1 -1
  235. package/src/yjs/yjs-types.ts +0 -2
  236. package/src/yjs/yjs-undo-plugin.ts +3 -2
  237. package/src/yjs/yjs.ts +6 -6
  238. package/dist/enter-rule-D-p4ykfv.js +0 -96
  239. package/dist/enter-rule-D-p4ykfv.js.map +0 -1
  240. package/dist/file-iLVR0eM0.js.map +0 -1
  241. package/dist/index-cp1u4e0e.d.ts.map +0 -1
  242. package/dist/input-rule-COGr_GBb.js +0 -90
  243. package/dist/input-rule-COGr_GBb.js.map +0 -1
  244. package/dist/mark-rule-CYe8zk4q.js.map +0 -1
  245. package/dist/paste-rule-BaDghcaU.js.map +0 -1
  246. package/dist/shiki-highlighter-chunk-DNNm2Vow.d.ts +0 -19
  247. package/dist/shiki-highlighter-chunk-DNNm2Vow.d.ts.map +0 -1
  248. package/dist/table-4oHfV-Ql.js.map +0 -1
@@ -1,6 +1,6 @@
1
1
  import { describe, expect, it } from 'vitest'
2
2
 
3
- import { splitTextByRegex } from './split-text-by-regex'
3
+ import { splitTextByRegex } from './split-text-by-regex.ts'
4
4
 
5
5
  describe('splitTextByRegex', () => {
6
6
  it('should return undefined when no matches are found', () => {
@@ -3,7 +3,7 @@ import type { ProseMirrorNode } from '@prosekit/pm/model'
3
3
  import { Plugin, PluginKey, type EditorState } from '@prosekit/pm/state'
4
4
  import { Decoration, DecorationSet } from '@prosekit/pm/view'
5
5
 
6
- import { findTable } from '../table'
6
+ import { findTable } from '../table/index.ts'
7
7
 
8
8
  export interface PlaceholderOptions {
9
9
  /**
@@ -11,7 +11,7 @@ import {
11
11
  } from '@prosekit/core'
12
12
  import type { Attrs } from '@prosekit/pm/model'
13
13
 
14
- import { defineMarkInputRule } from '../input-rule'
14
+ import { defineMarkInputRule } from '../input-rule/index.ts'
15
15
 
16
16
  /**
17
17
  * @internal
@@ -1,15 +1,14 @@
1
- export { defineTable, type TableExtension } from './table'
2
- export { defineTableCommands, type TableCommandsExtension } from './table-commands'
3
- export { exitTable } from './table-commands/exit-table'
4
- export { insertTable, type InsertTableOptions } from './table-commands/insert-table'
5
- export { moveTableColumn, type MoveTableColumnOptions } from './table-commands/move-table-column'
6
- export { moveTableRow, type MoveTableRowOptions } from './table-commands/move-table-row'
7
- export { selectTable, type SelectTableOptions } from './table-commands/select-table'
8
- export { selectTableCell, type SelectTableCellOptions } from './table-commands/select-table-cell'
9
- export { selectTableColumn, type SelectTableColumnOptions } from './table-commands/select-table-column'
10
- export { selectTableRow, type SelectTableRowOptions } from './table-commands/select-table-row'
11
- export { defineTableDropIndicator } from './table-drop-indicator'
12
- export { defineTablePlugins } from './table-plugins'
1
+ export { defineTableCommands, type TableCommandsExtension } from './table-commands.ts'
2
+ export { exitTable } from './table-commands/exit-table.ts'
3
+ export { insertTable, type InsertTableOptions } from './table-commands/insert-table.ts'
4
+ export { moveTableColumn, type MoveTableColumnOptions } from './table-commands/move-table-column.ts'
5
+ export { moveTableRow, type MoveTableRowOptions } from './table-commands/move-table-row.ts'
6
+ export { selectTableCell, type SelectTableCellOptions } from './table-commands/select-table-cell.ts'
7
+ export { selectTableColumn, type SelectTableColumnOptions } from './table-commands/select-table-column.ts'
8
+ export { selectTableRow, type SelectTableRowOptions } from './table-commands/select-table-row.ts'
9
+ export { selectTable, type SelectTableOptions } from './table-commands/select-table.ts'
10
+ export { defineTableDropIndicator } from './table-drop-indicator.ts'
11
+ export { defineTablePlugins } from './table-plugins.ts'
13
12
  export {
14
13
  defineTableCellSpec,
15
14
  defineTableHeaderCellSpec,
@@ -19,5 +18,6 @@ export {
19
18
  type TableHeaderCellSpecExtension,
20
19
  type TableRowSpecExtension,
21
20
  type TableSpecExtension,
22
- } from './table-spec'
23
- export { findTable, isCellSelection } from './table-utils'
21
+ } from './table-spec.ts'
22
+ export { findTable, isCellSelection } from './table-utils.ts'
23
+ export { defineTable, type TableExtension } from './table.ts'
@@ -1,8 +1,8 @@
1
1
  import { describe, expect, it } from 'vitest'
2
2
 
3
- import { setupTest } from '../../testing'
4
- import { isCellSelection } from '../table-utils'
5
- import { setCellSelection } from '../test-utils'
3
+ import { setupTest } from '../../testing/index.ts'
4
+ import { isCellSelection } from '../table-utils.ts'
5
+ import { setCellSelection } from '../test-utils.ts'
6
6
 
7
7
  describe('deleteCellSelection', () => {
8
8
  it('can clear the content in the selected table cells', () => {
@@ -1,7 +1,7 @@
1
1
  import { describe, expect, it } from 'vitest'
2
2
 
3
- import { setupTest } from '../../testing'
4
- import { inputText } from '../../testing/keyboard'
3
+ import { setupTest } from '../../testing/index.ts'
4
+ import { inputText } from '../../testing/keyboard.ts'
5
5
 
6
6
  describe('exitTable', () => {
7
7
  it('can exist a table', async () => {
@@ -1,6 +1,6 @@
1
1
  import { describe, expect, it } from 'vitest'
2
2
 
3
- import { setupTest } from '../../testing'
3
+ import { setupTest } from '../../testing/index.ts'
4
4
 
5
5
  describe('insertTable', () => {
6
6
  it('can insert a table', () => {
@@ -2,9 +2,9 @@ import type { Command } from '@prosekit/pm/state'
2
2
  import { CellSelection } from 'prosemirror-tables'
3
3
  import { describe, expect, it } from 'vitest'
4
4
 
5
- import { setupTest } from '../../testing'
5
+ import { setupTest } from '../../testing/index.ts'
6
6
 
7
- import { moveTableColumn } from './move-table-column'
7
+ import { moveTableColumn } from './move-table-column.ts'
8
8
 
9
9
  function setup() {
10
10
  const { editor, n } = setupTest()
@@ -2,9 +2,9 @@ import type { Command } from '@prosekit/pm/state'
2
2
  import { CellSelection } from 'prosemirror-tables'
3
3
  import { describe, expect, it } from 'vitest'
4
4
 
5
- import { setupTest } from '../../testing'
5
+ import { setupTest } from '../../testing/index.ts'
6
6
 
7
- import { moveTableRow } from './move-table-row'
7
+ import { moveTableRow } from './move-table-row.ts'
8
8
 
9
9
  function setup() {
10
10
  const { editor, n } = setupTest()
@@ -1,8 +1,8 @@
1
1
  import { describe, expect, it } from 'vitest'
2
2
 
3
- import { setupTest } from '../../testing'
4
- import { isCellSelection } from '../table-utils'
5
- import { inspectSelectedCells } from '../test-utils'
3
+ import { setupTest } from '../../testing/index.ts'
4
+ import { isCellSelection } from '../table-utils.ts'
5
+ import { inspectSelectedCells } from '../test-utils.ts'
6
6
 
7
7
  describe('selectTableCell', () => {
8
8
  it('can select a table cell', () => {
@@ -1,7 +1,7 @@
1
1
  import type { Command } from '@prosekit/pm/state'
2
2
  import { CellSelection } from 'prosemirror-tables'
3
3
 
4
- import { findCellPos } from '../table-utils'
4
+ import { findCellPos } from '../table-utils.ts'
5
5
 
6
6
  /**
7
7
  * @public
@@ -1,7 +1,7 @@
1
1
  import { describe, expect, it } from 'vitest'
2
2
 
3
- import { setupTest } from '../../testing'
4
- import { inspectSelectedCells } from '../test-utils'
3
+ import { setupTest } from '../../testing/index.ts'
4
+ import { inspectSelectedCells } from '../test-utils.ts'
5
5
 
6
6
  describe('selectTableColumn', () => {
7
7
  it('can select the whole table column', () => {
@@ -1,7 +1,7 @@
1
1
  import type { Command } from '@prosekit/pm/state'
2
2
  import { CellSelection } from 'prosemirror-tables'
3
3
 
4
- import { findCellRange } from '../table-utils'
4
+ import { findCellRange } from '../table-utils.ts'
5
5
 
6
6
  /**
7
7
  * @public
@@ -1,7 +1,7 @@
1
1
  import { describe, expect, it } from 'vitest'
2
2
 
3
- import { setupTest } from '../../testing'
4
- import { inspectSelectedCells } from '../test-utils'
3
+ import { setupTest } from '../../testing/index.ts'
4
+ import { inspectSelectedCells } from '../test-utils.ts'
5
5
 
6
6
  describe('selectTableRow', () => {
7
7
  it('can select the whole table row', () => {
@@ -1,7 +1,7 @@
1
1
  import type { Command } from '@prosekit/pm/state'
2
2
  import { CellSelection } from 'prosemirror-tables'
3
3
 
4
- import { findCellRange } from '../table-utils'
4
+ import { findCellRange } from '../table-utils.ts'
5
5
 
6
6
  /**
7
7
  * @public
@@ -1,7 +1,7 @@
1
1
  import { describe, expect, it } from 'vitest'
2
2
 
3
- import { setupTest } from '../../testing'
4
- import { inspectSelectedCells } from '../test-utils'
3
+ import { setupTest } from '../../testing/index.ts'
4
+ import { inspectSelectedCells } from '../test-utils.ts'
5
5
 
6
6
  describe('selectTable', () => {
7
7
  it('can select the whole table', () => {
@@ -1,7 +1,7 @@
1
1
  import type { Command } from '@prosekit/pm/state'
2
2
  import { CellSelection, TableMap } from 'prosemirror-tables'
3
3
 
4
- import { findTable } from '../table-utils'
4
+ import { findTable } from '../table-utils.ts'
5
5
 
6
6
  /**
7
7
  * @public
@@ -11,15 +11,15 @@ import {
11
11
  splitCell,
12
12
  } from 'prosemirror-tables'
13
13
 
14
- import { deleteCellSelection } from './table-commands/delete-cell-selection'
15
- import { exitTable } from './table-commands/exit-table'
16
- import { insertTable, type InsertTableOptions } from './table-commands/insert-table'
17
- import { moveTableColumn, type MoveTableColumnOptions } from './table-commands/move-table-column'
18
- import { moveTableRow, type MoveTableRowOptions } from './table-commands/move-table-row'
19
- import { selectTable, type SelectTableOptions } from './table-commands/select-table'
20
- import { selectTableCell, type SelectTableCellOptions } from './table-commands/select-table-cell'
21
- import { selectTableColumn, type SelectTableColumnOptions } from './table-commands/select-table-column'
22
- import { selectTableRow, type SelectTableRowOptions } from './table-commands/select-table-row'
14
+ import { deleteCellSelection } from './table-commands/delete-cell-selection.ts'
15
+ import { exitTable } from './table-commands/exit-table.ts'
16
+ import { insertTable, type InsertTableOptions } from './table-commands/insert-table.ts'
17
+ import { moveTableColumn, type MoveTableColumnOptions } from './table-commands/move-table-column.ts'
18
+ import { moveTableRow, type MoveTableRowOptions } from './table-commands/move-table-row.ts'
19
+ import { selectTableCell, type SelectTableCellOptions } from './table-commands/select-table-cell.ts'
20
+ import { selectTableColumn, type SelectTableColumnOptions } from './table-commands/select-table-column.ts'
21
+ import { selectTableRow, type SelectTableRowOptions } from './table-commands/select-table-row.ts'
22
+ import { selectTable, type SelectTableOptions } from './table-commands/select-table.ts'
23
23
 
24
24
  /**
25
25
  * @internal
@@ -1,7 +1,7 @@
1
1
  import type { PlainExtension } from '@prosekit/core'
2
2
 
3
- import type { DragEventHandler } from '../drop-indicator'
4
- import { defineDropIndicator } from '../drop-indicator'
3
+ import type { DragEventHandler } from '../drop-indicator/index.ts'
4
+ import { defineDropIndicator } from '../drop-indicator/index.ts'
5
5
 
6
6
  /**
7
7
  * Hides the drop indicator when dragging a table column or row by using the
@@ -2,11 +2,11 @@ import { union } from '@prosekit/core'
2
2
  import pick from 'just-pick'
3
3
  import { describe, expect, it } from 'vitest'
4
4
 
5
- import { defineDoc } from '../doc'
6
- import { defineParagraph } from '../paragraph'
7
- import { defineText } from '../text'
5
+ import { defineDoc } from '../doc/index.ts'
6
+ import { defineParagraph } from '../paragraph/index.ts'
7
+ import { defineText } from '../text/index.ts'
8
8
 
9
- import { defineTableCellSpec, defineTableHeaderCellSpec, defineTableRowSpec, defineTableSpec } from './table-spec'
9
+ import { defineTableCellSpec, defineTableHeaderCellSpec, defineTableRowSpec, defineTableSpec } from './table-spec.ts'
10
10
 
11
11
  describe('table spec', () => {
12
12
  it('should be defined', () => {
@@ -1,8 +1,8 @@
1
1
  import { union, type Union } from '@prosekit/core'
2
2
 
3
- import { defineTableCommands, type TableCommandsExtension } from './table-commands'
4
- import { defineTableDropIndicator } from './table-drop-indicator'
5
- import { defineTablePlugins } from './table-plugins'
3
+ import { defineTableCommands, type TableCommandsExtension } from './table-commands.ts'
4
+ import { defineTableDropIndicator } from './table-drop-indicator.ts'
5
+ import { defineTablePlugins } from './table-plugins.ts'
6
6
  import {
7
7
  defineTableCellSpec,
8
8
  defineTableHeaderCellSpec,
@@ -12,7 +12,7 @@ import {
12
12
  type TableHeaderCellSpecExtension,
13
13
  type TableRowSpecExtension,
14
14
  type TableSpecExtension,
15
- } from './table-spec'
15
+ } from './table-spec.ts'
16
16
 
17
17
  /**
18
18
  * @internal
@@ -1,7 +1,7 @@
1
1
  import type { Command, Selection } from '@prosekit/pm/state'
2
2
  import { CellSelection } from 'prosemirror-tables'
3
3
 
4
- import { isCellSelection } from './table-utils'
4
+ import { isCellSelection } from './table-utils.ts'
5
5
 
6
6
  // Helper to create a cell selection between two positions
7
7
  export function setCellSelection(from: number, to: number): Command {
@@ -13,28 +13,30 @@ import {
13
13
  import { createTestEditor, type TestEditor } from '@prosekit/core/test'
14
14
  import { keyboard } from 'vitest-browser-commands/playwright'
15
15
 
16
- import { defineBackgroundColor } from '../background-color'
17
- import { defineBlockquote } from '../blockquote'
18
- import { defineBold } from '../bold'
19
- import { defineCode } from '../code'
20
- import { defineCodeBlock } from '../code-block'
21
- import { defineDoc } from '../doc'
22
- import { defineHardBreak } from '../hard-break'
23
- import { defineHeading } from '../heading'
24
- import { defineHorizontalRule } from '../horizontal-rule'
25
- import { defineImage } from '../image'
26
- import { defineItalic } from '../italic'
27
- import { defineLink } from '../link'
28
- import { defineList, type ListAttrs } from '../list'
29
- import { defineParagraph } from '../paragraph'
30
- import { defineStrike } from '../strike'
31
- import { defineTable } from '../table'
32
- import type { CellAttrs } from '../table/table-spec'
33
- import { defineText } from '../text'
34
- import { defineTextColor } from '../text-color'
35
- import { defineUnderline } from '../underline'
36
-
37
- import { readHtmlTextFromClipboard, readPlainTextFromClipboard } from './clipboard'
16
+ import { defineBackgroundColor } from '../background-color/index.ts'
17
+ import { defineBlockquote } from '../blockquote/index.ts'
18
+ import { defineBold } from '../bold/index.ts'
19
+ import { defineCodeBlock } from '../code-block/index.ts'
20
+ import { defineCode } from '../code/index.ts'
21
+ import { defineDoc } from '../doc/index.ts'
22
+ import { defineHardBreak } from '../hard-break/index.ts'
23
+ import { defineHeading } from '../heading/index.ts'
24
+ import { defineHorizontalRule } from '../horizontal-rule/index.ts'
25
+ import { defineImage } from '../image/index.ts'
26
+ import { defineItalic } from '../italic/index.ts'
27
+ import { defineLink } from '../link/index.ts'
28
+ import { defineList, type ListAttrs } from '../list/index.ts'
29
+ import { defineMath } from '../math/index.ts'
30
+ import { defineParagraph } from '../paragraph/index.ts'
31
+ import { defineStrike } from '../strike/index.ts'
32
+ import { defineTable } from '../table/index.ts'
33
+ import type { CellAttrs } from '../table/table-spec.ts'
34
+ import { defineTextColor } from '../text-color/index.ts'
35
+ import { defineText } from '../text/index.ts'
36
+ import { defineUnderline } from '../underline/index.ts'
37
+
38
+ import { readHtmlTextFromClipboard, readPlainTextFromClipboard } from './clipboard.ts'
39
+ import { renderMathBlock, renderMathInline } from './katex.ts'
38
40
 
39
41
  /**
40
42
  * @internal
@@ -63,6 +65,7 @@ export function defineTestExtension() {
63
65
  defineHorizontalRule(),
64
66
  defineHardBreak(),
65
67
  defineCodeBlock(),
68
+ defineMath({ renderMathBlock, renderMathInline }),
66
69
  )
67
70
  }
68
71
 
@@ -0,0 +1,9 @@
1
+ import { render } from 'katex'
2
+
3
+ export function renderMathBlock(text: string, element: HTMLElement) {
4
+ render(text, element, { displayMode: true, throwOnError: false, output: 'mathml' })
5
+ }
6
+
7
+ export function renderMathInline(text: string, element: HTMLElement) {
8
+ render(text, element, { displayMode: false, throwOnError: false, output: 'mathml' })
9
+ }
@@ -1,3 +1,3 @@
1
- export { defineTextColor, type TextColorExtension } from './text-color'
2
- export { addTextColor, defineTextColorCommands, removeTextColor, type TextColorCommandsExtension } from './text-color-commands'
3
- export { defineTextColorSpec, type TextColorAttrs, type TextColorSpecExtension } from './text-color-spec'
1
+ export { addTextColor, defineTextColorCommands, removeTextColor, type TextColorCommandsExtension } from './text-color-commands.ts'
2
+ export { defineTextColorSpec, type TextColorAttrs, type TextColorSpecExtension } from './text-color-spec.ts'
3
+ export { defineTextColor, type TextColorExtension } from './text-color.ts'
@@ -1,6 +1,6 @@
1
1
  import { describe, expect, it } from 'vitest'
2
2
 
3
- import { setupTest } from '../testing'
3
+ import { setupTest } from '../testing/index.ts'
4
4
 
5
5
  describe('addTextColor', () => {
6
6
  it('can add color to text', () => {
@@ -1,7 +1,7 @@
1
1
  import { addMark, defineCommands, removeMark, type Extension } from '@prosekit/core'
2
2
  import type { Command } from '@prosekit/pm/state'
3
3
 
4
- import type { TextColorAttrs } from './text-color-spec'
4
+ import type { TextColorAttrs } from './text-color-spec.ts'
5
5
 
6
6
  /**
7
7
  * @internal
@@ -1,7 +1,7 @@
1
1
  import { formatHTML } from 'diffable-html-snapshot'
2
2
  import { describe, expect, it } from 'vitest'
3
3
 
4
- import { setupTest } from '../testing'
4
+ import { setupTest } from '../testing/index.ts'
5
5
 
6
6
  describe('defineTextColorSpec', () => {
7
7
  it('should render color as inline span with style attribute', () => {
@@ -1,7 +1,7 @@
1
1
  import { union, type Union } from '@prosekit/core'
2
2
 
3
- import { defineTextColorCommands, type TextColorCommandsExtension } from './text-color-commands'
4
- import { defineTextColorSpec, type TextColorSpecExtension } from './text-color-spec'
3
+ import { defineTextColorCommands, type TextColorCommandsExtension } from './text-color-commands.ts'
4
+ import { defineTextColorSpec, type TextColorSpecExtension } from './text-color-spec.ts'
5
5
 
6
6
  /**
7
7
  * @internal
package/src/yjs/index.ts CHANGED
@@ -1,7 +1,7 @@
1
- export { defineYjs, type YjsExtension, type YjsOptions } from './yjs'
2
- export { defineYjsCommands } from './yjs-commands'
3
- export { defineYjsCursorPlugin, type YjsCursorOptions, type YjsCursorPluginOptions } from './yjs-cursor-plugin'
4
- export { defineYjsKeymap } from './yjs-keymap'
5
- export { defineYjsSyncPlugin, type YjsSyncOptions, type YjsSyncPluginOptions } from './yjs-sync-plugin'
6
- export type { Awareness } from './yjs-types'
7
- export { defineYjsUndoPlugin, type YjsUndoOptions, type YjsUndoPluginOptions } from './yjs-undo-plugin'
1
+ export { defineYjsCommands } from './yjs-commands.ts'
2
+ export { defineYjsCursorPlugin, type YjsCursorOptions, type YjsCursorPluginOptions } from './yjs-cursor-plugin.ts'
3
+ export { defineYjsKeymap } from './yjs-keymap.ts'
4
+ export { defineYjsSyncPlugin, type YjsSyncOptions, type YjsSyncPluginOptions } from './yjs-sync-plugin.ts'
5
+ export type { Awareness } from './yjs-types.ts'
6
+ export { defineYjsUndoPlugin, type YjsUndoOptions, type YjsUndoPluginOptions } from './yjs-undo-plugin.ts'
7
+ export { defineYjs, type YjsExtension, type YjsOptions } from './yjs.ts'
@@ -2,7 +2,7 @@ import { definePlugin, type PlainExtension } from '@prosekit/core'
2
2
  import type { Plugin } from '@prosekit/pm/state'
3
3
  import { yCursorPlugin } from 'y-prosemirror'
4
4
 
5
- import type { Awareness } from './yjs-types'
5
+ import type { Awareness } from './yjs-types.ts'
6
6
 
7
7
  /**
8
8
  * Options for `y-prosemirror`'s `yCursorPlugin`.
@@ -1,7 +1,5 @@
1
1
  import type { yCursorPlugin } from 'y-prosemirror'
2
2
 
3
- // TODO: Remove `import type { Awareness } from 'y-protocols/awareness'` from examples.
4
-
5
3
  /**
6
4
  * @internal
7
5
  *
@@ -1,7 +1,7 @@
1
1
  import { definePlugin, type PlainExtension } from '@prosekit/core'
2
2
  import type { ProseMirrorPlugin } from '@prosekit/pm/state'
3
3
  import type { EditorView } from '@prosekit/pm/view'
4
- import { yUndoPlugin as originalYUndoPlugin, yUndoPluginKey } from 'y-prosemirror'
4
+ import { yUndoPlugin as originalYUndoPlugin, yUndoPluginKey, type UndoPluginState } from 'y-prosemirror'
5
5
  import type { UndoManager as YjsUndoManager } from 'yjs'
6
6
 
7
7
  type UndoManager = YjsUndoManager & { restore: () => void }
@@ -12,7 +12,8 @@ type UndoManager = YjsUndoManager & { restore: () => void }
12
12
  function fixYUndoPlugin(yUndoPluginInstance: ProseMirrorPlugin) {
13
13
  const originalUndoPluginView = yUndoPluginInstance.spec.view
14
14
  yUndoPluginInstance.spec.view = (view: EditorView) => {
15
- const pluginState = yUndoPluginKey.getState(view.state)
15
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- The type definition in y-prosemirror is not correct. An explicit file extension should be added to this line: https://npmx.dev/package-code/y-prosemirror/v/1.3.7/dist%2Fsrc%2Fplugins%2Fkeys.d.ts#L13
16
+ const pluginState: UndoPluginState | undefined = yUndoPluginKey.getState(view.state)
16
17
  if (!pluginState) {
17
18
  return {}
18
19
  }
package/src/yjs/yjs.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  import { Priority, union, withPriority, type PlainExtension, type Union } from '@prosekit/core'
2
2
  import type * as Y from 'yjs'
3
3
 
4
- import { defineYjsCommands, type YjsCommandsExtension } from './yjs-commands'
5
- import { defineYjsCursorPlugin, type YjsCursorPluginOptions } from './yjs-cursor-plugin'
6
- import { defineYjsKeymap } from './yjs-keymap'
7
- import { defineYjsSyncPlugin, type YjsSyncPluginOptions } from './yjs-sync-plugin'
8
- import type { Awareness } from './yjs-types'
9
- import { defineYjsUndoPlugin, type YjsUndoPluginOptions } from './yjs-undo-plugin'
4
+ import { defineYjsCommands, type YjsCommandsExtension } from './yjs-commands.ts'
5
+ import { defineYjsCursorPlugin, type YjsCursorPluginOptions } from './yjs-cursor-plugin.ts'
6
+ import { defineYjsKeymap } from './yjs-keymap.ts'
7
+ import { defineYjsSyncPlugin, type YjsSyncPluginOptions } from './yjs-sync-plugin.ts'
8
+ import type { Awareness } from './yjs-types.ts'
9
+ import { defineYjsUndoPlugin, type YjsUndoPluginOptions } from './yjs-undo-plugin.ts'
10
10
 
11
11
  export interface YjsOptions {
12
12
  /**
@@ -1,96 +0,0 @@
1
- import { OBJECT_REPLACEMENT_CHARACTER, defineFacet, defineFacetPayload, getNodeType, isTextSelection, maybeRun, pluginFacet } from "@prosekit/core";
2
- import { PluginKey, ProseMirrorPlugin } from "@prosekit/pm/state";
3
- import { keydownHandler } from "@prosekit/pm/keymap";
4
-
5
- //#region src/enter-rule/index.ts
6
- /**
7
- * Defines an enter rule. An enter rule applies when the text directly in front of
8
- * the cursor matches `regex` and user presses Enter. The `regex` should end
9
- * with `$`.
10
- *
11
- * @param options
12
- *
13
- * @public
14
- */
15
- function defineEnterRule({ regex, handler, stop = false }) {
16
- return defineFacetPayload(enterRule, [new EnterRule(regex, handler, stop)]);
17
- }
18
- /**
19
- * Defines an enter rule that replaces the matched text with a block node.
20
- *
21
- * See also {@link defineEnterRule}.
22
- *
23
- * @param options
24
- *
25
- * @public
26
- */
27
- function defineTextBlockEnterRule({ regex, type, attrs, stop = true }) {
28
- return defineEnterRule({
29
- regex,
30
- handler: ({ state, from, to, match }) => {
31
- const nodeType = getNodeType(state.schema, type);
32
- const $start = state.doc.resolve(from);
33
- if (!$start.node(-1).canReplaceWith($start.index(-1), $start.indexAfter(-1), nodeType)) return null;
34
- const nodeAttrs = maybeRun(attrs, match);
35
- return state.tr.delete(from, to).setBlockType(from, from, nodeType, nodeAttrs);
36
- },
37
- stop
38
- });
39
- }
40
- /**
41
- * @internal
42
- */
43
- var EnterRule = class {
44
- constructor(regex, handler, stop) {
45
- this.regex = regex;
46
- this.handler = handler;
47
- this.stop = stop;
48
- }
49
- };
50
- const enterRule = defineFacet({
51
- reduce: () => {
52
- let rules = [];
53
- const command = (state, dispatch, view) => {
54
- if (!view) return false;
55
- return execRules(view, rules, dispatch);
56
- };
57
- const handler = keydownHandler({ Enter: command });
58
- const plugin = new ProseMirrorPlugin({
59
- key: new PluginKey("prosekit-enter-rule"),
60
- props: { handleKeyDown: handler }
61
- });
62
- return function reducer(inputs) {
63
- rules = inputs;
64
- return plugin;
65
- };
66
- },
67
- parent: pluginFacet
68
- });
69
- function execRules(view, rules, dispatch) {
70
- if (view.composing) return false;
71
- const state = view.state;
72
- const selection = state.selection;
73
- if (!isTextSelection(selection)) return false;
74
- const $cursor = selection.$cursor;
75
- if (!$cursor || $cursor.parent.type.spec.code) return false;
76
- const textBefore = $cursor.parent.textBetween(Math.max(0, $cursor.parentOffset - MAX_MATCH), $cursor.parentOffset, null, OBJECT_REPLACEMENT_CHARACTER);
77
- for (const rule of rules) {
78
- rule.regex.lastIndex = 0;
79
- const match = rule.regex.exec(textBefore);
80
- const tr = match && rule.handler({
81
- state,
82
- from: $cursor.pos - match[0].length,
83
- to: $cursor.pos,
84
- match
85
- });
86
- if (!tr) continue;
87
- dispatch?.(tr);
88
- if (rule.stop) return true;
89
- }
90
- return false;
91
- }
92
- const MAX_MATCH = 200;
93
-
94
- //#endregion
95
- export { defineTextBlockEnterRule as n, defineEnterRule as t };
96
- //# sourceMappingURL=enter-rule-D-p4ykfv.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"enter-rule-D-p4ykfv.js","names":[],"sources":["../src/enter-rule/index.ts"],"sourcesContent":["import {\n defineFacet,\n defineFacetPayload,\n getNodeType,\n isTextSelection,\n maybeRun,\n OBJECT_REPLACEMENT_CHARACTER,\n pluginFacet,\n type PlainExtension,\n type PluginPayload,\n} from '@prosekit/core'\nimport { keydownHandler } from '@prosekit/pm/keymap'\nimport type { Attrs, NodeType } from '@prosekit/pm/model'\nimport { PluginKey, ProseMirrorPlugin, type Command, type EditorState, type Transaction } from '@prosekit/pm/state'\nimport type { EditorView } from '@prosekit/pm/view'\n\n/**\n * @public\n *\n * Options for {@link EnterRuleHandler}.\n */\nexport interface EnterRuleHandlerOptions {\n /**\n * The current editor state.\n */\n state: EditorState\n\n /**\n * The start position of the matched text.\n */\n from: number\n\n /**\n * The end position of the matched text.\n */\n to: number\n\n /**\n * The matched result from the regular expression.\n */\n match: RegExpExecArray\n}\n\n/**\n * @public\n */\nexport type EnterRuleHandler = (options: EnterRuleHandlerOptions) => Transaction | null\n\n/**\n * Options for {@link defineEnterRule}.\n *\n * @public\n */\nexport type EnterRuleOptions = {\n /**\n * The regular expression to match against. It should end with `$`.\n */\n regex: RegExp\n\n /**\n * A function to be called when an enter rule is triggered.\n */\n handler: EnterRuleHandler\n\n /**\n * Whether to stop further handlers from being called if this rule is triggered.\n *\n * @default false\n */\n stop?: boolean\n}\n\n/**\n * Options for {@link defineTextBlockEnterRule}.\n *\n * @public\n */\nexport interface TextBlockEnterRuleOptions {\n /**\n * The regular expression to match against. It should end with `$`.\n */\n regex: RegExp\n\n /**\n * The node type to replace the matched text with.\n */\n type: string | NodeType\n\n /**\n * Attributes to set on the node. If a function is provided, it will be called\n * with the matched result from the regular expression.\n */\n attrs?: Attrs | null | ((match: RegExpMatchArray) => Attrs | null)\n\n /**\n * Whether to stop further handlers from being called if this rule is triggered.\n *\n * @default true\n */\n stop?: boolean\n}\n\n/**\n * Defines an enter rule. An enter rule applies when the text directly in front of\n * the cursor matches `regex` and user presses Enter. The `regex` should end\n * with `$`.\n *\n * @param options\n *\n * @public\n */\nexport function defineEnterRule({\n regex,\n handler,\n stop = false,\n}: EnterRuleOptions): PlainExtension {\n const rule: EnterRule = new EnterRule(regex, handler, stop)\n return defineFacetPayload(enterRule, [rule]) as PlainExtension\n}\n\n/**\n * Defines an enter rule that replaces the matched text with a block node.\n *\n * See also {@link defineEnterRule}.\n *\n * @param options\n *\n * @public\n */\nexport function defineTextBlockEnterRule({\n regex,\n type,\n attrs,\n stop = true,\n}: TextBlockEnterRuleOptions): PlainExtension {\n return defineEnterRule({\n regex,\n handler: ({ state, from, to, match }) => {\n const nodeType = getNodeType(state.schema, type)\n const $start = state.doc.resolve(from)\n\n if (\n !$start\n .node(-1)\n .canReplaceWith($start.index(-1), $start.indexAfter(-1), nodeType)\n ) {\n return null\n }\n\n const nodeAttrs = maybeRun(attrs, match)\n return state.tr\n .delete(from, to)\n .setBlockType(from, from, nodeType, nodeAttrs)\n },\n stop,\n })\n}\n\n/**\n * @internal\n */\nclass EnterRule {\n constructor(\n readonly regex: RegExp,\n readonly handler: EnterRuleHandler,\n readonly stop: boolean,\n ) {}\n}\n\nconst enterRule = defineFacet<EnterRule, PluginPayload>({\n reduce: () => {\n let rules: EnterRule[] = []\n\n const command: Command = (state, dispatch, view) => {\n if (!view) return false\n return execRules(view, rules, dispatch)\n }\n const handler = keydownHandler({ Enter: command })\n const plugin = new ProseMirrorPlugin({\n key: new PluginKey('prosekit-enter-rule'),\n props: { handleKeyDown: handler },\n })\n\n return function reducer(inputs) {\n rules = inputs\n return plugin\n }\n },\n\n parent: pluginFacet,\n})\n\nfunction execRules(\n view: EditorView,\n rules: readonly EnterRule[],\n dispatch?: (tr: Transaction) => void,\n): boolean {\n if (view.composing) return false\n const state = view.state\n const selection = state.selection\n if (!isTextSelection(selection)) return false\n const $cursor = selection.$cursor\n if (!$cursor || $cursor.parent.type.spec.code) return false\n\n const textBefore = $cursor.parent.textBetween(\n Math.max(0, $cursor.parentOffset - MAX_MATCH),\n $cursor.parentOffset,\n null,\n OBJECT_REPLACEMENT_CHARACTER,\n )\n\n for (const rule of rules) {\n rule.regex.lastIndex = 0\n const match = rule.regex.exec(textBefore)\n const tr = match\n && rule.handler({\n state,\n from: $cursor.pos - match[0].length,\n to: $cursor.pos,\n match,\n })\n if (!tr) continue\n dispatch?.(tr)\n\n if (rule.stop) {\n return true\n }\n }\n return false\n}\n\nconst MAX_MATCH = 200\n"],"mappings":";;;;;;;;;;;;;;AA+GA,SAAgB,gBAAgB,EAC9B,OACA,SACA,OAAO,SAC4B;AAEnC,QAAO,mBAAmB,WAAW,CADb,IAAI,UAAU,OAAO,SAAS,KAAK,CAChB,CAAC;;;;;;;;;;;AAY9C,SAAgB,yBAAyB,EACvC,OACA,MACA,OACA,OAAO,QACqC;AAC5C,QAAO,gBAAgB;EACrB;EACA,UAAU,EAAE,OAAO,MAAM,IAAI,YAAY;GACvC,MAAM,WAAW,YAAY,MAAM,QAAQ,KAAK;GAChD,MAAM,SAAS,MAAM,IAAI,QAAQ,KAAK;AAEtC,OACE,CAAC,OACE,KAAK,GAAG,CACR,eAAe,OAAO,MAAM,GAAG,EAAE,OAAO,WAAW,GAAG,EAAE,SAAS,CAEpE,QAAO;GAGT,MAAM,YAAY,SAAS,OAAO,MAAM;AACxC,UAAO,MAAM,GACV,OAAO,MAAM,GAAG,CAChB,aAAa,MAAM,MAAM,UAAU,UAAU;;EAElD;EACD,CAAC;;;;;AAMJ,IAAM,YAAN,MAAgB;CACd,YACE,AAAS,OACT,AAAS,SACT,AAAS,MACT;EAHS;EACA;EACA;;;AAIb,MAAM,YAAY,YAAsC;CACtD,cAAc;EACZ,IAAI,QAAqB,EAAE;EAE3B,MAAM,WAAoB,OAAO,UAAU,SAAS;AAClD,OAAI,CAAC,KAAM,QAAO;AAClB,UAAO,UAAU,MAAM,OAAO,SAAS;;EAEzC,MAAM,UAAU,eAAe,EAAE,OAAO,SAAS,CAAC;EAClD,MAAM,SAAS,IAAI,kBAAkB;GACnC,KAAK,IAAI,UAAU,sBAAsB;GACzC,OAAO,EAAE,eAAe,SAAS;GAClC,CAAC;AAEF,SAAO,SAAS,QAAQ,QAAQ;AAC9B,WAAQ;AACR,UAAO;;;CAIX,QAAQ;CACT,CAAC;AAEF,SAAS,UACP,MACA,OACA,UACS;AACT,KAAI,KAAK,UAAW,QAAO;CAC3B,MAAM,QAAQ,KAAK;CACnB,MAAM,YAAY,MAAM;AACxB,KAAI,CAAC,gBAAgB,UAAU,CAAE,QAAO;CACxC,MAAM,UAAU,UAAU;AAC1B,KAAI,CAAC,WAAW,QAAQ,OAAO,KAAK,KAAK,KAAM,QAAO;CAEtD,MAAM,aAAa,QAAQ,OAAO,YAChC,KAAK,IAAI,GAAG,QAAQ,eAAe,UAAU,EAC7C,QAAQ,cACR,MACA,6BACD;AAED,MAAK,MAAM,QAAQ,OAAO;AACxB,OAAK,MAAM,YAAY;EACvB,MAAM,QAAQ,KAAK,MAAM,KAAK,WAAW;EACzC,MAAM,KAAK,SACN,KAAK,QAAQ;GACd;GACA,MAAM,QAAQ,MAAM,MAAM,GAAG;GAC7B,IAAI,QAAQ;GACZ;GACD,CAAC;AACJ,MAAI,CAAC,GAAI;AACT,aAAW,GAAG;AAEd,MAAI,KAAK,KACP,QAAO;;AAGX,QAAO;;AAGT,MAAM,YAAY"}