@prosekit/core 0.9.0 → 0.10.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 (123) hide show
  1. package/dist/{editor-4lgGc3CY.d.ts → editor-BULC1zqX.d.ts} +12 -12
  2. package/dist/editor-BULC1zqX.d.ts.map +1 -0
  3. package/dist/{editor-DGNUXn-u.js → editor-g-Rqn-ZE.js} +30 -30
  4. package/dist/editor-g-Rqn-ZE.js.map +1 -0
  5. package/dist/prosekit-core-test.d.ts +1 -2
  6. package/dist/prosekit-core-test.d.ts.map +1 -1
  7. package/dist/prosekit-core-test.js +1 -1
  8. package/dist/prosekit-core-test.js.map +1 -1
  9. package/dist/prosekit-core.d.ts +103 -24
  10. package/dist/prosekit-core.d.ts.map +1 -1
  11. package/dist/prosekit-core.js +116 -35
  12. package/dist/prosekit-core.js.map +1 -1
  13. package/package.json +6 -7
  14. package/src/commands/add-mark.ts +1 -4
  15. package/src/commands/expand-mark.ts +2 -9
  16. package/src/commands/insert-default-block.spec.ts +1 -5
  17. package/src/commands/insert-default-block.ts +1 -4
  18. package/src/commands/insert-node.ts +4 -8
  19. package/src/commands/remove-mark.ts +1 -4
  20. package/src/commands/remove-node.ts +2 -2
  21. package/src/commands/select-block.spec.ts +4 -6
  22. package/src/commands/select-block.ts +1 -4
  23. package/src/commands/set-block-type.ts +1 -4
  24. package/src/commands/set-node-attrs-between.spec.ts +221 -0
  25. package/src/commands/set-node-attrs-between.ts +77 -0
  26. package/src/commands/set-node-attrs.spec.ts +129 -0
  27. package/src/commands/set-node-attrs.ts +25 -26
  28. package/src/commands/toggle-mark.ts +1 -4
  29. package/src/commands/toggle-node.ts +2 -5
  30. package/src/commands/toggle-wrap.spec.ts +1 -5
  31. package/src/commands/toggle-wrap.ts +1 -4
  32. package/src/commands/unset-block-type.spec.ts +1 -5
  33. package/src/commands/unset-block-type.ts +2 -8
  34. package/src/commands/unset-mark.spec.ts +1 -5
  35. package/src/commands/wrap.ts +1 -4
  36. package/src/editor/action.spec.ts +2 -6
  37. package/src/editor/action.ts +1 -8
  38. package/src/editor/editor.spec.ts +2 -9
  39. package/src/editor/editor.ts +11 -45
  40. package/src/editor/union.spec.ts +1 -5
  41. package/src/editor/union.ts +1 -4
  42. package/src/extensions/clipboard-serializer.ts +4 -16
  43. package/src/extensions/command.ts +16 -48
  44. package/src/extensions/default-state.spec.ts +1 -5
  45. package/src/extensions/default-state.ts +2 -8
  46. package/src/extensions/events/dom-event.spec.ts +1 -6
  47. package/src/extensions/events/dom-event.ts +4 -16
  48. package/src/extensions/events/editor-event.ts +4 -16
  49. package/src/extensions/events/focus.spec.ts +1 -6
  50. package/src/extensions/events/plugin-view.ts +2 -9
  51. package/src/extensions/history.ts +2 -9
  52. package/src/extensions/keymap-base.spec.ts +2 -11
  53. package/src/extensions/keymap-base.ts +1 -4
  54. package/src/extensions/keymap.spec.ts +6 -20
  55. package/src/extensions/keymap.ts +3 -13
  56. package/src/extensions/mark-spec.spec.ts +5 -20
  57. package/src/extensions/mark-spec.ts +4 -15
  58. package/src/extensions/mark-view-effect.ts +3 -9
  59. package/src/extensions/mark-view.ts +2 -8
  60. package/src/extensions/node-spec.spec.ts +5 -21
  61. package/src/extensions/node-spec.ts +4 -15
  62. package/src/extensions/node-view-effect.ts +3 -9
  63. package/src/extensions/node-view.ts +2 -8
  64. package/src/extensions/plugin.spec.ts +3 -16
  65. package/src/extensions/plugin.ts +3 -12
  66. package/src/facets/base-extension.ts +1 -4
  67. package/src/facets/command.ts +2 -8
  68. package/src/facets/facet-extension.spec.ts +4 -15
  69. package/src/facets/facet-node.spec.ts +2 -9
  70. package/src/facets/facet-node.ts +4 -9
  71. package/src/facets/facet.spec.ts +1 -4
  72. package/src/facets/schema-spec.ts +2 -9
  73. package/src/facets/schema.ts +3 -12
  74. package/src/facets/state.spec.ts +2 -9
  75. package/src/facets/state.ts +4 -18
  76. package/src/facets/union-extension.ts +2 -8
  77. package/src/index.ts +40 -166
  78. package/src/test/index.ts +1 -4
  79. package/src/test/test-builder.ts +1 -4
  80. package/src/test/test-editor.spec.ts +1 -5
  81. package/src/test/test-editor.ts +5 -24
  82. package/src/testing/index.ts +18 -14
  83. package/src/types/extension.spec.ts +1 -4
  84. package/src/types/extension.ts +3 -13
  85. package/src/types/simplify-union.ts +1 -4
  86. package/src/utils/array-grouping.spec.ts +1 -4
  87. package/src/utils/attrs-match.ts +1 -5
  88. package/src/utils/clsx.spec.ts +1 -4
  89. package/src/utils/combine-event-handlers.spec.ts +1 -5
  90. package/src/utils/default-block-at.ts +1 -4
  91. package/src/utils/editor-content.spec.ts +1 -4
  92. package/src/utils/editor-content.ts +4 -16
  93. package/src/utils/find-node.ts +65 -0
  94. package/src/utils/find-parent-node-of-type.ts +6 -12
  95. package/src/utils/find-parent-node.spec.ts +1 -5
  96. package/src/utils/find-parent-node.ts +1 -4
  97. package/src/utils/get-custom-selection.ts +1 -5
  98. package/src/utils/get-mark-type.ts +1 -4
  99. package/src/utils/get-node-type.ts +1 -4
  100. package/src/utils/get-node-types.ts +1 -4
  101. package/src/utils/includes-mark.ts +1 -5
  102. package/src/utils/is-at-block-start.ts +1 -4
  103. package/src/utils/is-mark-absent.spec.ts +1 -4
  104. package/src/utils/is-mark-absent.ts +1 -5
  105. package/src/utils/is-mark-active.ts +1 -4
  106. package/src/utils/is-node-active.spec.ts +109 -0
  107. package/src/utils/is-node-active.ts +17 -8
  108. package/src/utils/is-subset.spec.ts +1 -4
  109. package/src/utils/maybe-run.spec.ts +1 -5
  110. package/src/utils/merge-objects.spec.ts +1 -4
  111. package/src/utils/merge-objects.ts +2 -1
  112. package/src/utils/merge-specs.ts +1 -4
  113. package/src/utils/object-equal.spec.ts +1 -4
  114. package/src/utils/output-spec.test.ts +1 -5
  115. package/src/utils/output-spec.ts +2 -10
  116. package/src/utils/parse.spec.ts +2 -11
  117. package/src/utils/parse.ts +3 -15
  118. package/src/utils/remove-undefined-values.spec.ts +1 -4
  119. package/src/utils/set-selection-around.ts +1 -4
  120. package/src/utils/type-assertion.ts +2 -21
  121. package/src/utils/unicode.spec.ts +1 -4
  122. package/dist/editor-4lgGc3CY.d.ts.map +0 -1
  123. package/dist/editor-DGNUXn-u.js.map +0 -1
@@ -1,8 +1,5 @@
1
1
  import { toggleMark as baseToggleMark } from '@prosekit/pm/commands'
2
- import type {
3
- Attrs,
4
- MarkType,
5
- } from '@prosekit/pm/model'
2
+ import type { Attrs, MarkType } from '@prosekit/pm/model'
6
3
  import type { Command } from '@prosekit/pm/state'
7
4
 
8
5
  import type { CommandCreator } from '../types/extension-command'
@@ -1,8 +1,5 @@
1
1
  import { setBlockType } from '@prosekit/pm/commands'
2
- import type {
3
- Attrs,
4
- NodeType,
5
- } from '@prosekit/pm/model'
2
+ import type { Attrs, NodeType } from '@prosekit/pm/model'
6
3
  import type { Command } from '@prosekit/pm/state'
7
4
 
8
5
  import { getNodeType } from '../utils/get-node-type'
@@ -24,7 +21,7 @@ export interface ToggleNodeOptions {
24
21
  }
25
22
 
26
23
  /**
27
- * Returns a command that set the selected textblocks to the given node type
24
+ * Returns a command that sets the selected textblocks to the given node type
28
25
  * with the given attributes.
29
26
  *
30
27
  * @param options
@@ -1,8 +1,4 @@
1
- import {
2
- describe,
3
- expect,
4
- it,
5
- } from 'vitest'
1
+ import { describe, expect, it } from 'vitest'
6
2
 
7
3
  import { setupTest } from '../testing'
8
4
 
@@ -1,8 +1,5 @@
1
1
  import { lift } from '@prosekit/pm/commands'
2
- import type {
3
- Attrs,
4
- NodeType,
5
- } from '@prosekit/pm/model'
2
+ import type { Attrs, NodeType } from '@prosekit/pm/model'
6
3
  import type { Command } from '@prosekit/pm/state'
7
4
 
8
5
  import { isNodeActive } from '../utils/is-node-active'
@@ -1,8 +1,4 @@
1
- import {
2
- describe,
3
- expect,
4
- it,
5
- } from 'vitest'
1
+ import { describe, expect, it } from 'vitest'
6
2
 
7
3
  import { setupTest } from '../testing'
8
4
 
@@ -1,11 +1,5 @@
1
- import {
2
- Fragment,
3
- Slice,
4
- } from '@prosekit/pm/model'
5
- import type {
6
- Command,
7
- Transaction,
8
- } from '@prosekit/pm/state'
1
+ import { Fragment, Slice } from '@prosekit/pm/model'
2
+ import type { Command, Transaction } from '@prosekit/pm/state'
9
3
  import { ReplaceAroundStep } from '@prosekit/pm/transform'
10
4
 
11
5
  import type { CommandCreator } from '../types/extension-command'
@@ -1,8 +1,4 @@
1
- import {
2
- describe,
3
- expect,
4
- it,
5
- } from 'vitest'
1
+ import { describe, expect, it } from 'vitest'
6
2
 
7
3
  import { setupTest } from '../testing'
8
4
 
@@ -1,7 +1,4 @@
1
- import type {
2
- Attrs,
3
- NodeType,
4
- } from '@prosekit/pm/model'
1
+ import type { Attrs, NodeType } from '@prosekit/pm/model'
5
2
  import type { Command } from '@prosekit/pm/state'
6
3
  import { findWrapping } from '@prosekit/pm/transform'
7
4
 
@@ -1,8 +1,4 @@
1
- import {
2
- describe,
3
- expect,
4
- it,
5
- } from 'vitest'
1
+ import { describe, expect, it } from 'vitest'
6
2
 
7
3
  import { setupTest } from '../testing'
8
4
  import { jsonFromNode } from '../utils/parse'
@@ -22,7 +18,7 @@ describe('NodeAction', () => {
22
18
  it('can apply node with attrs', () => {
23
19
  expect(n.codeBlock({ language: 'javascript' }, 'foo').toJSON()).toEqual({
24
20
  type: 'codeBlock',
25
- attrs: { language: 'javascript' },
21
+ attrs: { language: 'javascript', lineNumbers: false },
26
22
  content: [{ text: 'foo', type: 'text' }],
27
23
  })
28
24
  })
@@ -1,12 +1,5 @@
1
1
  import { mapValues } from '@ocavue/utils'
2
- import type {
3
- Attrs,
4
- Mark,
5
- MarkType,
6
- NodeType,
7
- ProseMirrorNode,
8
- Schema,
9
- } from '@prosekit/pm/model'
2
+ import type { Attrs, Mark, MarkType, NodeType, ProseMirrorNode, Schema } from '@prosekit/pm/model'
10
3
  import type { EditorState } from '@prosekit/pm/state'
11
4
 
12
5
  import { ProseKitError } from '../error'
@@ -1,15 +1,8 @@
1
- import {
2
- describe,
3
- expect,
4
- it,
5
- } from 'vitest'
1
+ import { describe, expect, it } from 'vitest'
6
2
 
7
3
  import { insertText } from '../commands/insert-text'
8
4
  import { wrap } from '../commands/wrap'
9
- import {
10
- defineTestExtension,
11
- setupTest,
12
- } from '../testing'
5
+ import { defineTestExtension, setupTest } from '../testing'
13
6
  import type { NodeJSON } from '../types/model'
14
7
 
15
8
  import { createEditor } from './editor'
@@ -1,29 +1,12 @@
1
1
  import { isDeepEqual } from '@ocavue/utils'
2
- import type {
3
- ProseMirrorNode,
4
- Schema,
5
- } from '@prosekit/pm/model'
6
- import {
7
- EditorState,
8
- type Command,
9
- type Plugin,
10
- type Selection,
11
- type Transaction,
12
- } from '@prosekit/pm/state'
13
- import {
14
- EditorView,
15
- type DirectEditorProps,
16
- type EditorProps,
17
- } from '@prosekit/pm/view'
2
+ import type { ProseMirrorNode, Schema } from '@prosekit/pm/model'
3
+ import { EditorState, type Command, type Plugin, type Selection, type Transaction } from '@prosekit/pm/state'
4
+ import { EditorView, type DirectEditorProps, type EditorProps } from '@prosekit/pm/view'
18
5
 
19
6
  import { ProseKitError } from '../error'
20
7
  import { defineDefaultState } from '../extensions/default-state'
21
8
  import type { BaseExtension } from '../facets/base-extension'
22
- import {
23
- subtractFacetNode,
24
- unionFacetNode,
25
- type FacetNode,
26
- } from '../facets/facet-node'
9
+ import { subtractFacetNode, unionFacetNode, type FacetNode } from '../facets/facet-node'
27
10
  import type {
28
11
  Extension,
29
12
  ExtractCommandActions,
@@ -32,31 +15,13 @@ import type {
32
15
  ExtractNodeActions,
33
16
  ExtractNodeNames,
34
17
  } from '../types/extension'
35
- import type {
36
- CommandAction,
37
- CommandCreator,
38
- } from '../types/extension-command'
39
- import type {
40
- NodeJSON,
41
- SelectionJSON,
42
- } from '../types/model'
18
+ import type { CommandAction, CommandCreator } from '../types/extension-command'
19
+ import type { NodeJSON, SelectionJSON } from '../types/model'
43
20
  import { assert } from '../utils/assert'
44
- import {
45
- getEditorContentDoc,
46
- getEditorSelection,
47
- } from '../utils/editor-content'
48
- import {
49
- htmlFromNode,
50
- jsonFromNode,
51
- type DOMDocumentOptions,
52
- } from '../utils/parse'
53
-
54
- import {
55
- createMarkActions,
56
- createNodeActions,
57
- type MarkAction,
58
- type NodeAction,
59
- } from './action'
21
+ import { getEditorContentDoc, getEditorSelection } from '../utils/editor-content'
22
+ import { htmlFromNode, jsonFromNode, type DOMDocumentOptions } from '../utils/parse'
23
+
24
+ import { createMarkActions, createNodeActions, type MarkAction, type NodeAction } from './action'
60
25
  import { union } from './union'
61
26
 
62
27
  /**
@@ -297,6 +262,7 @@ export class EditorInstance {
297
262
  }
298
263
  this.view = new EditorView({ mount: place }, this.directEditorProps)
299
264
  this.afterMounted.forEach((callback) => callback())
265
+ this.afterMounted.length = 0
300
266
  }
301
267
 
302
268
  public unmount(): void {
@@ -1,10 +1,6 @@
1
1
  import type { Attrs } from '@prosekit/pm/model'
2
2
  import type { Command } from '@prosekit/pm/state'
3
- import {
4
- describe,
5
- expectTypeOf,
6
- it,
7
- } from 'vitest'
3
+ import { describe, expectTypeOf, it } from 'vitest'
8
4
 
9
5
  import { defineCommands } from '../extensions/command'
10
6
  import { defineMarkSpec } from '../extensions/mark-spec'
@@ -1,9 +1,6 @@
1
1
  import type { BaseExtension } from '../facets/base-extension'
2
2
  import { UnionExtensionImpl } from '../facets/union-extension'
3
- import type {
4
- Extension,
5
- Union,
6
- } from '../types/extension'
3
+ import type { Extension, Union } from '../types/extension'
7
4
  import { assert } from '../utils/assert'
8
5
 
9
6
  /**
@@ -1,25 +1,13 @@
1
- import {
2
- DOMSerializer,
3
- type DOMOutputSpec,
4
- type Mark,
5
- type ProseMirrorNode,
6
- type Schema,
7
- } from '@prosekit/pm/model'
8
- import {
9
- PluginKey,
10
- ProseMirrorPlugin,
11
- } from '@prosekit/pm/state'
1
+ import { isNotNullish } from '@ocavue/utils'
2
+ import { DOMSerializer, type DOMOutputSpec, type Mark, type ProseMirrorNode, type Schema } from '@prosekit/pm/model'
3
+ import { PluginKey, ProseMirrorPlugin } from '@prosekit/pm/state'
12
4
 
13
5
  import { defineFacet } from '../facets/facet'
14
6
  import { defineFacetPayload } from '../facets/facet-extension'
15
7
  import type { AnyFunction } from '../types/any-function'
16
8
  import type { PlainExtension } from '../types/extension'
17
- import { isNotNullish } from '../utils/type-assertion'
18
9
 
19
- import {
20
- pluginFacet,
21
- type PluginPayload,
22
- } from './plugin'
10
+ import { pluginFacet, type PluginPayload } from './plugin'
23
11
 
24
12
  type SerializeFragmentFunction = typeof DOMSerializer.prototype.serializeFragment
25
13
  type SerializeNodeFunction = typeof DOMSerializer.prototype.serializeNode
@@ -1,53 +1,18 @@
1
- import {
2
- addMark,
3
- type AddMarkOptions,
4
- } from '../commands/add-mark'
5
- import {
6
- insertDefaultBlock,
7
- type InsertDefaultBlockOptions,
8
- } from '../commands/insert-default-block'
9
- import {
10
- insertNode,
11
- type InsertNodeOptions,
12
- } from '../commands/insert-node'
13
- import {
14
- insertText,
15
- type InsertTextOptions,
16
- } from '../commands/insert-text'
17
- import {
18
- removeMark,
19
- type RemoveMarkOptions,
20
- } from '../commands/remove-mark'
21
- import {
22
- removeNode,
23
- type RemoveNodeOptions,
24
- } from '../commands/remove-node'
1
+ import { addMark, type AddMarkOptions } from '../commands/add-mark'
2
+ import { insertDefaultBlock, type InsertDefaultBlockOptions } from '../commands/insert-default-block'
3
+ import { insertNode, type InsertNodeOptions } from '../commands/insert-node'
4
+ import { insertText, type InsertTextOptions } from '../commands/insert-text'
5
+ import { removeMark, type RemoveMarkOptions } from '../commands/remove-mark'
6
+ import { removeNode, type RemoveNodeOptions } from '../commands/remove-node'
25
7
  import { selectAll } from '../commands/select-all'
26
8
  import { selectBlock } from '../commands/select-block'
27
- import {
28
- setBlockType,
29
- type SetBlockTypeOptions,
30
- } from '../commands/set-block-type'
31
- import {
32
- setNodeAttrs,
33
- type SetNodeAttrsOptions,
34
- } from '../commands/set-node-attrs'
35
- import {
36
- toggleWrap,
37
- type ToggleWrapOptions,
38
- } from '../commands/toggle-wrap'
39
- import {
40
- unsetBlockType,
41
- type UnsetBlockTypeOptions,
42
- } from '../commands/unset-block-type'
43
- import {
44
- unsetMark,
45
- type UnsetMarkOptions,
46
- } from '../commands/unset-mark'
47
- import {
48
- wrap,
49
- type WrapOptions,
50
- } from '../commands/wrap'
9
+ import { setBlockType, type SetBlockTypeOptions } from '../commands/set-block-type'
10
+ import { setNodeAttrs, type SetNodeAttrsOptions } from '../commands/set-node-attrs'
11
+ import { setNodeAttrsBetween, type SetNodeAttrsBetweenOptions } from '../commands/set-node-attrs-between'
12
+ import { toggleWrap, type ToggleWrapOptions } from '../commands/toggle-wrap'
13
+ import { unsetBlockType, type UnsetBlockTypeOptions } from '../commands/unset-block-type'
14
+ import { unsetMark, type UnsetMarkOptions } from '../commands/unset-mark'
15
+ import { wrap, type WrapOptions } from '../commands/wrap'
51
16
  import { commandFacet } from '../facets/command'
52
17
  import { defineFacetPayload } from '../facets/facet-extension'
53
18
  import type { Extension } from '../types/extension'
@@ -77,6 +42,7 @@ export type BaseCommandsExtension = Extension<{
77
42
  toggleWrap: [options: ToggleWrapOptions]
78
43
  setBlockType: [options: SetBlockTypeOptions]
79
44
  setNodeAttrs: [options: SetNodeAttrsOptions]
45
+ setNodeAttrsBetween: [options: SetNodeAttrsBetweenOptions]
80
46
  insertDefaultBlock: [options?: InsertDefaultBlockOptions]
81
47
  selectAll: []
82
48
  selectBlock: []
@@ -108,6 +74,8 @@ export function defineBaseCommands(): BaseCommandsExtension {
108
74
 
109
75
  setNodeAttrs,
110
76
 
77
+ setNodeAttrsBetween,
78
+
111
79
  insertDefaultBlock,
112
80
 
113
81
  selectAll,
@@ -1,8 +1,4 @@
1
- import {
2
- describe,
3
- expect,
4
- it,
5
- } from 'vitest'
1
+ import { describe, expect, it } from 'vitest'
6
2
 
7
3
  import { createEditor } from '../editor/editor'
8
4
  import { defineTestExtension } from '../testing'
@@ -1,15 +1,9 @@
1
- import {
2
- Selection,
3
- type EditorStateConfig,
4
- } from '@prosekit/pm/state'
1
+ import { Selection, type EditorStateConfig } from '@prosekit/pm/state'
5
2
 
6
3
  import { defineFacetPayload } from '../facets/facet-extension'
7
4
  import { stateFacet } from '../facets/state'
8
5
  import type { PlainExtension } from '../types/extension'
9
- import type {
10
- NodeJSON,
11
- SelectionJSON,
12
- } from '../types/model'
6
+ import type { NodeJSON, SelectionJSON } from '../types/model'
13
7
  import { getEditorContentJSON } from '../utils/editor-content'
14
8
 
15
9
  /**
@@ -1,9 +1,4 @@
1
- import {
2
- describe,
3
- expect,
4
- it,
5
- vi,
6
- } from 'vitest'
1
+ import { describe, expect, it, vi } from 'vitest'
7
2
 
8
3
  import { createEditor } from '../../editor/editor'
9
4
  import { defineTestExtension } from '../../testing'
@@ -1,25 +1,13 @@
1
- import {
2
- PluginKey,
3
- ProseMirrorPlugin,
4
- } from '@prosekit/pm/state'
5
- import type {
6
- DOMEventMap,
7
- EditorView,
8
- } from '@prosekit/pm/view'
1
+ import { PluginKey, ProseMirrorPlugin } from '@prosekit/pm/state'
2
+ import type { DOMEventMap, EditorView } from '@prosekit/pm/view'
9
3
 
10
- import {
11
- defineFacet,
12
- type Facet,
13
- } from '../../facets/facet'
4
+ import { defineFacet, type Facet } from '../../facets/facet'
14
5
  import { defineFacetPayload } from '../../facets/facet-extension'
15
6
  import type { PlainExtension } from '../../types/extension'
16
7
  import type { Setter } from '../../types/setter'
17
8
  import { groupEntries } from '../../utils/array-grouping'
18
9
  import { combineEventHandlers } from '../../utils/combine-event-handlers'
19
- import {
20
- pluginFacet,
21
- type PluginPayload,
22
- } from '../plugin'
10
+ import { pluginFacet, type PluginPayload } from '../plugin'
23
11
 
24
12
  /**
25
13
  * A function to handle the events fired on the editable DOM element. Returns
@@ -1,26 +1,14 @@
1
1
  import type { ObjectEntries } from '@ocavue/utils'
2
- import type {
3
- Node,
4
- Slice,
5
- } from '@prosekit/pm/model'
6
- import {
7
- PluginKey,
8
- ProseMirrorPlugin,
9
- } from '@prosekit/pm/state'
2
+ import type { Node, Slice } from '@prosekit/pm/model'
3
+ import { PluginKey, ProseMirrorPlugin } from '@prosekit/pm/state'
10
4
  import type { EditorView } from '@prosekit/pm/view'
11
5
 
12
- import {
13
- defineFacet,
14
- type Facet,
15
- } from '../../facets/facet'
6
+ import { defineFacet, type Facet } from '../../facets/facet'
16
7
  import { defineFacetPayload } from '../../facets/facet-extension'
17
8
  import type { PlainExtension } from '../../types/extension'
18
9
  import { groupEntries } from '../../utils/array-grouping'
19
10
  import { combineEventHandlers } from '../../utils/combine-event-handlers'
20
- import {
21
- pluginFacet,
22
- type PluginPayload,
23
- } from '../plugin'
11
+ import { pluginFacet, type PluginPayload } from '../plugin'
24
12
 
25
13
  export type KeyDownHandler = (
26
14
  view: EditorView,
@@ -1,9 +1,4 @@
1
- import {
2
- describe,
3
- expect,
4
- it,
5
- vi,
6
- } from 'vitest'
1
+ import { describe, expect, it, vi } from 'vitest'
7
2
 
8
3
  import { createEditor } from '../../editor/editor'
9
4
  import { union } from '../../editor/union'
@@ -1,17 +1,10 @@
1
- import {
2
- PluginKey,
3
- ProseMirrorPlugin,
4
- type EditorState,
5
- } from '@prosekit/pm/state'
1
+ import { PluginKey, ProseMirrorPlugin, type EditorState } from '@prosekit/pm/state'
6
2
  import type { EditorView } from '@prosekit/pm/view'
7
3
 
8
4
  import { defineFacet } from '../../facets/facet'
9
5
  import { defineFacetPayload } from '../../facets/facet-extension'
10
6
  import type { PlainExtension } from '../../types/extension'
11
- import {
12
- pluginFacet,
13
- type PluginPayload,
14
- } from '../plugin'
7
+ import { pluginFacet, type PluginPayload } from '../plugin'
15
8
 
16
9
  /**
17
10
  * A function that is called when the editor view is mounted.
@@ -1,18 +1,11 @@
1
- import {
2
- history,
3
- redo,
4
- undo,
5
- } from '@prosekit/pm/history'
1
+ import { history, redo, undo } from '@prosekit/pm/history'
6
2
 
7
3
  import { union } from '../editor/union'
8
4
  import type { Extension } from '../types/extension'
9
5
  import { isApple } from '../utils/env'
10
6
 
11
7
  import { defineCommands } from './command'
12
- import {
13
- defineKeymap,
14
- type Keymap,
15
- } from './keymap'
8
+ import { defineKeymap, type Keymap } from './keymap'
16
9
  import { definePlugin } from './plugin'
17
10
 
18
11
  const keymap: Keymap = {
@@ -1,18 +1,9 @@
1
- import {
2
- describe,
3
- expect,
4
- it,
5
- } from 'vitest'
1
+ import { describe, expect, it } from 'vitest'
6
2
  import { keyboard } from 'vitest-browser-commands/playwright'
7
3
 
8
4
  import { union } from '../editor/union'
9
5
  import type { TestEditor } from '../test'
10
- import {
11
- defineDoc,
12
- defineParagraph,
13
- defineText,
14
- setupTestFromExtension,
15
- } from '../testing'
6
+ import { defineDoc, defineParagraph, defineText, setupTestFromExtension } from '../testing'
16
7
  import type { SelectionJSON } from '../types/model'
17
8
 
18
9
  import { defineBaseKeymap } from './keymap-base'
@@ -16,10 +16,7 @@ import { withPriority } from '../editor/with-priority'
16
16
  import type { PlainExtension } from '../types/extension'
17
17
  import { Priority } from '../types/priority'
18
18
 
19
- import {
20
- defineKeymap,
21
- type Keymap,
22
- } from './keymap'
19
+ import { defineKeymap, type Keymap } from './keymap'
23
20
 
24
21
  // Replace `splitBlock` with `splitSplittableBlock`
25
22
  const customEnter = chainCommands(
@@ -1,27 +1,13 @@
1
1
  import type { Command } from '@prosekit/pm/state'
2
- import {
3
- describe,
4
- expect,
5
- it,
6
- vi,
7
- } from 'vitest'
2
+ import { describe, expect, it, vi } from 'vitest'
8
3
  import { keyboard } from 'vitest-browser-commands/playwright'
9
4
 
10
5
  import { union } from '../editor/union'
11
6
  import { withPriority } from '../editor/with-priority'
12
- import {
13
- defineDoc,
14
- defineParagraph,
15
- defineText,
16
- setupTest,
17
- setupTestFromExtension,
18
- } from '../testing'
7
+ import { defineDoc, defineParagraph, defineText, setupTest, setupTestFromExtension } from '../testing'
19
8
  import { Priority } from '../types/priority'
20
9
 
21
- import {
22
- defineKeymap,
23
- type Keymap,
24
- } from './keymap'
10
+ import { defineKeymap, type Keymap } from './keymap'
25
11
 
26
12
  describe('keymap', () => {
27
13
  it('can register and unregister keymap', () => {
@@ -161,9 +147,9 @@ describe('keymap', () => {
161
147
  ]
162
148
 
163
149
  for (const key of keybindings) {
164
- let command: Command = record(key)
165
- let keymap: Keymap = { [key]: command }
166
- let extension = defineKeymap(keymap)
150
+ const command: Command = record(key)
151
+ const keymap: Keymap = { [key]: command }
152
+ const extension = defineKeymap(keymap)
167
153
  editor.use(extension)
168
154
  }
169
155
 
@@ -1,22 +1,12 @@
1
1
  import { keydownHandler } from '@prosekit/pm/keymap'
2
- import {
3
- Plugin,
4
- PluginKey,
5
- type Command,
6
- } from '@prosekit/pm/state'
2
+ import { Plugin, PluginKey, type Command } from '@prosekit/pm/state'
7
3
  import type { EditorView } from '@prosekit/pm/view'
8
4
 
9
- import {
10
- defineFacet,
11
- type Facet,
12
- } from '../facets/facet'
5
+ import { defineFacet, type Facet } from '../facets/facet'
13
6
  import { defineFacetPayload } from '../facets/facet-extension'
14
7
  import type { PlainExtension } from '../types/extension'
15
8
 
16
- import {
17
- pluginFacet,
18
- type PluginPayload,
19
- } from './plugin'
9
+ import { pluginFacet, type PluginPayload } from './plugin'
20
10
 
21
11
  /**
22
12
  * A set of keybindings. Please read the