@prosekit/core 0.8.6 → 0.9.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 (57) hide show
  1. package/dist/{editor-M9OimMiI.d.ts → editor-4lgGc3CY.d.ts} +20 -60
  2. package/dist/editor-4lgGc3CY.d.ts.map +1 -0
  3. package/dist/{editor-D2iEkgO8.js → editor-DGNUXn-u.js} +99 -116
  4. package/dist/editor-DGNUXn-u.js.map +1 -0
  5. package/dist/prosekit-core-test.d.ts +1 -1
  6. package/dist/prosekit-core-test.js +1 -1
  7. package/dist/prosekit-core.d.ts +89 -180
  8. package/dist/prosekit-core.d.ts.map +1 -1
  9. package/dist/prosekit-core.js +322 -381
  10. package/dist/prosekit-core.js.map +1 -1
  11. package/package.json +7 -8
  12. package/src/commands/select-all.ts +3 -8
  13. package/src/commands/select-block.spec.ts +83 -0
  14. package/src/commands/select-block.ts +59 -0
  15. package/src/commands/wrap.ts +1 -6
  16. package/src/editor/action.ts +1 -11
  17. package/src/editor/editor.ts +20 -32
  18. package/src/extensions/command.ts +4 -0
  19. package/src/extensions/default-state.spec.ts +0 -4
  20. package/src/extensions/default-state.ts +4 -24
  21. package/src/extensions/events/dom-event.ts +1 -4
  22. package/src/extensions/events/editor-event.ts +1 -1
  23. package/src/extensions/history.ts +1 -1
  24. package/src/extensions/keymap-base.spec.ts +98 -0
  25. package/src/extensions/keymap-base.ts +37 -13
  26. package/src/extensions/keymap.spec.ts +74 -1
  27. package/src/extensions/keymap.ts +19 -31
  28. package/src/extensions/mark-spec.ts +32 -29
  29. package/src/extensions/node-spec.ts +28 -19
  30. package/src/extensions/plugin.ts +1 -2
  31. package/src/facets/command.ts +8 -2
  32. package/src/facets/state.spec.ts +6 -6
  33. package/src/facets/state.ts +1 -2
  34. package/src/index.ts +3 -23
  35. package/src/types/extension-command.ts +0 -7
  36. package/src/types/extension.ts +0 -16
  37. package/src/utils/array-grouping.spec.ts +1 -11
  38. package/src/utils/array-grouping.ts +1 -14
  39. package/src/utils/array.ts +0 -4
  40. package/src/utils/combine-event-handlers.ts +4 -6
  41. package/src/utils/editor-content.ts +3 -3
  42. package/src/utils/env.ts +2 -0
  43. package/src/utils/output-spec.ts +11 -0
  44. package/src/utils/parse.ts +9 -9
  45. package/dist/editor-D2iEkgO8.js.map +0 -1
  46. package/dist/editor-M9OimMiI.d.ts.map +0 -1
  47. package/src/extensions/doc.ts +0 -31
  48. package/src/extensions/paragraph.ts +0 -61
  49. package/src/extensions/text.ts +0 -34
  50. package/src/types/base-node-view-options.ts +0 -33
  51. package/src/types/object-entries.ts +0 -13
  52. package/src/utils/collect-children.ts +0 -21
  53. package/src/utils/collect-nodes.ts +0 -37
  54. package/src/utils/deep-equals.spec.ts +0 -26
  55. package/src/utils/deep-equals.ts +0 -29
  56. package/src/utils/get-id.spec.ts +0 -14
  57. package/src/utils/get-id.ts +0 -13
@@ -6,15 +6,20 @@ import {
6
6
  joinTextblockBackward,
7
7
  liftEmptyBlock,
8
8
  newlineInCode,
9
+ selectAll,
9
10
  selectNodeBackward,
10
11
  } from '@prosekit/pm/commands'
11
12
  import { splitSplittableBlock } from 'prosemirror-splittable'
12
13
 
14
+ import { selectBlockCommand } from '../commands/select-block'
13
15
  import { withPriority } from '../editor/with-priority'
14
16
  import type { PlainExtension } from '../types/extension'
15
17
  import { Priority } from '../types/priority'
16
18
 
17
- import { defineKeymap } from './keymap'
19
+ import {
20
+ defineKeymap,
21
+ type Keymap,
22
+ } from './keymap'
18
23
 
19
24
  // Replace `splitBlock` with `splitSplittableBlock`
20
25
  const customEnter = chainCommands(
@@ -31,30 +36,49 @@ const customBackspace = chainCommands(
31
36
  selectNodeBackward,
32
37
  )
33
38
 
34
- const customBaseKeymap = {
35
- ...baseKeymap,
36
- Enter: customEnter,
37
- Backspace: customBackspace,
38
- }
39
-
40
39
  /**
41
40
  * @internal
42
41
  */
43
42
  export type BaseKeymapExtension = PlainExtension
44
43
 
45
44
  /**
46
- * Defines some basic key bindings.
47
- *
48
45
  * @public
49
46
  */
50
- export function defineBaseKeymap(options?: {
47
+ export interface BaseKeymapOptions {
51
48
  /**
52
49
  * The priority of the keymap.
53
50
  *
54
51
  * @default Priority.low
55
52
  */
56
53
  priority?: Priority
57
- }): BaseKeymapExtension {
58
- const priority = options?.priority ?? Priority.low
59
- return withPriority(defineKeymap(customBaseKeymap), priority)
54
+
55
+ /**
56
+ * If `true`, the first `Mod-a` press selects the current block that the
57
+ * cursor is in, and a second press selects the entire document.
58
+ *
59
+ * If `false`, `Mod-a` immediately selects the entire document.
60
+ *
61
+ * @default true
62
+ */
63
+ preferBlockSelection?: boolean
64
+ }
65
+
66
+ /**
67
+ * Defines some basic key bindings.
68
+ *
69
+ * @param options
70
+ *
71
+ * @public
72
+ */
73
+ export function defineBaseKeymap({
74
+ priority = Priority.low,
75
+ preferBlockSelection = true,
76
+ }: BaseKeymapOptions = {}): BaseKeymapExtension {
77
+ const keymap: Keymap = {
78
+ ...baseKeymap,
79
+ 'Mod-a': preferBlockSelection ? chainCommands(selectBlockCommand, selectAll) : selectAll,
80
+ 'Enter': customEnter,
81
+ 'Backspace': customBackspace,
82
+ }
83
+ return withPriority(defineKeymap(keymap), priority)
60
84
  }
@@ -5,10 +5,17 @@ import {
5
5
  it,
6
6
  vi,
7
7
  } from 'vitest'
8
+ import { keyboard } from 'vitest-browser-commands/playwright'
8
9
 
9
10
  import { union } from '../editor/union'
10
11
  import { withPriority } from '../editor/with-priority'
11
- import { setupTest } from '../testing'
12
+ import {
13
+ defineDoc,
14
+ defineParagraph,
15
+ defineText,
16
+ setupTest,
17
+ setupTestFromExtension,
18
+ } from '../testing'
12
19
  import { Priority } from '../types/priority'
13
20
 
14
21
  import {
@@ -122,4 +129,70 @@ describe('keymap', () => {
122
129
  // Highest priority should be called first
123
130
  expect(callOrder).toEqual(['highest', 'default', 'lowest'])
124
131
  })
132
+
133
+ it('can merge keybindings with different variants', async () => {
134
+ const called: string[] = []
135
+ const { editor } = setupTestFromExtension(union(
136
+ defineDoc(),
137
+ defineText(),
138
+ defineParagraph(),
139
+ ))
140
+
141
+ const record = (label: string): Command => {
142
+ return () => {
143
+ called.push(label)
144
+ return false
145
+ }
146
+ }
147
+
148
+ const keybindings = [
149
+ // Match Ctrl-b
150
+ 'ctrl-b',
151
+ 'CTRL-b',
152
+
153
+ // Match Ctrl-Shift-b
154
+ 'c-B',
155
+ 'ctrl-shift-b',
156
+ 'c-s-B',
157
+ 'Ctrl-B',
158
+
159
+ // Do not match
160
+ 'ctrl-c',
161
+ ]
162
+
163
+ for (const key of keybindings) {
164
+ let command: Command = record(key)
165
+ let keymap: Keymap = { [key]: command }
166
+ let extension = defineKeymap(keymap)
167
+ editor.use(extension)
168
+ }
169
+
170
+ called.length = 0
171
+ await keyboard.down('Control')
172
+ await keyboard.down('b')
173
+ await keyboard.up('b')
174
+ await keyboard.up('Control')
175
+ expect(called).toMatchInlineSnapshot(`
176
+ [
177
+ "CTRL-b",
178
+ "ctrl-b",
179
+ ]
180
+ `)
181
+
182
+ called.length = 0
183
+ await keyboard.down('Control')
184
+ await keyboard.down('Shift')
185
+ await keyboard.down('B')
186
+ await keyboard.up('B')
187
+ await keyboard.up('Shift')
188
+ await keyboard.up('Control')
189
+ expect(called).toMatchInlineSnapshot(`
190
+ [
191
+ "Ctrl-B",
192
+ "c-s-B",
193
+ "ctrl-shift-b",
194
+ "c-B",
195
+ ]
196
+ `)
197
+ })
125
198
  })
@@ -1,4 +1,3 @@
1
- import { chainCommands } from '@prosekit/pm/commands'
2
1
  import { keydownHandler } from '@prosekit/pm/keymap'
3
2
  import {
4
3
  Plugin,
@@ -6,7 +5,6 @@ import {
6
5
  type Command,
7
6
  } from '@prosekit/pm/state'
8
7
  import type { EditorView } from '@prosekit/pm/view'
9
- import mapValues from 'just-map-values'
10
8
 
11
9
  import {
12
10
  defineFacet,
@@ -14,7 +12,6 @@ import {
14
12
  } from '../facets/facet'
15
13
  import { defineFacetPayload } from '../facets/facet-extension'
16
14
  import type { PlainExtension } from '../types/extension'
17
- import { toReversed } from '../utils/array'
18
15
 
19
16
  import {
20
17
  pluginFacet,
@@ -22,6 +19,9 @@ import {
22
19
  } from './plugin'
23
20
 
24
21
  /**
22
+ * A set of keybindings. Please read the
23
+ * [documentation](https://prosemirror.net/docs/ref/#keymap) for more details.
24
+ *
25
25
  * @public
26
26
  */
27
27
  export interface Keymap {
@@ -29,6 +29,9 @@ export interface Keymap {
29
29
  }
30
30
 
31
31
  /**
32
+ * Adds a set of keybindings to the editor. Please read the
33
+ * [documentation](https://prosemirror.net/docs/ref/#keymap) for more details.
34
+ *
32
35
  * @public
33
36
  */
34
37
  export function defineKeymap(keymap: Keymap): PlainExtension {
@@ -48,27 +51,29 @@ export const keymapFacet: Facet<KeymapPayload, PluginPayload> = defineFacet<
48
51
  PluginPayload
49
52
  >({
50
53
  reduce: () => {
51
- type Handler = (view: EditorView, event: KeyboardEvent) => boolean
54
+ type KeydownHandler = (view: EditorView, event: KeyboardEvent) => boolean
52
55
 
53
- let handler: Handler | undefined
56
+ // An array of keymap handlers, ordered from the highest priority to the lowest.
57
+ let subHandlers: KeydownHandler[] = []
54
58
 
55
- const handlerWrapper: Handler = (view, event) => {
56
- if (handler) return handler(view, event)
59
+ // A root handler that combines all the sub handlers.
60
+ const rootHandler: KeydownHandler = (view, event) => {
61
+ for (const handler of subHandlers) {
62
+ if (handler(view, event)) return true
63
+ }
57
64
  return false
58
65
  }
59
66
 
60
67
  const plugin = new Plugin({
61
68
  key: keymapPluginKey,
62
- props: { handleKeyDown: handlerWrapper },
69
+ props: { handleKeyDown: rootHandler },
63
70
  })
64
71
 
65
72
  return (keymaps: Keymap[]) => {
66
- handler = keydownHandler(
67
- mergeKeymaps(
68
- // The keymap at the end have a higher priority.
69
- toReversed(keymaps),
70
- ),
71
- )
73
+ // The keymap at the end has a higher priority, so we need to reverse the
74
+ // order here.
75
+ subHandlers = keymaps.map(keydownHandler).reverse()
76
+
72
77
  return plugin
73
78
  }
74
79
  },
@@ -76,21 +81,4 @@ export const keymapFacet: Facet<KeymapPayload, PluginPayload> = defineFacet<
76
81
  singleton: true,
77
82
  })
78
83
 
79
- function mergeKeymaps(keymaps: Keymap[]): Keymap {
80
- const bindings: Record<string, Command[]> = {}
81
-
82
- for (const keymap of keymaps) {
83
- for (const [key, command] of Object.entries(keymap)) {
84
- const commands = bindings[key] || (bindings[key] = [])
85
- commands.push(command)
86
- }
87
- }
88
-
89
- return mapValues(bindings, mergeCommands)
90
- }
91
-
92
- function mergeCommands(commands: Command[]): Command {
93
- return chainCommands(...commands)
94
- }
95
-
96
84
  const keymapPluginKey = new PluginKey('prosekit-keymap')
@@ -1,9 +1,9 @@
1
+ import { mapGroupBy } from '@ocavue/utils'
1
2
  import type {
3
+ AttributeSpec,
2
4
  MarkSpec,
3
- ParseRule,
4
5
  SchemaSpec,
5
6
  } from '@prosekit/pm/model'
6
- import clone from 'just-clone'
7
7
  import OrderedMap from 'orderedmap'
8
8
 
9
9
  import { defineFacet } from '../facets/facet'
@@ -14,12 +14,11 @@ import type {
14
14
  AttrSpec,
15
15
  } from '../types/attrs'
16
16
  import type { Extension } from '../types/extension'
17
- import { groupBy } from '../utils/array-grouping'
18
17
  import { assert } from '../utils/assert'
19
18
  import { mergeSpecs } from '../utils/merge-specs'
20
19
  import {
21
20
  wrapOutputSpecAttrs,
22
- wrapTagParseRuleAttrs,
21
+ wrapParseRuleAttrs,
23
22
  } from '../utils/output-spec'
24
23
  import { isNotNullish } from '../utils/type-assertion'
25
24
 
@@ -76,7 +75,24 @@ export interface MarkAttrOptions<
76
75
  }
77
76
 
78
77
  /**
78
+ * Defines a mark type into the editor schema.
79
+ *
79
80
  * @public
81
+ *
82
+ * @example
83
+ *
84
+ * ```ts
85
+ * const extension = defineMarkSpec({
86
+ * name: 'bold',
87
+ * parseDOM: [
88
+ * { tag: 'strong' },
89
+ * { tag: 'b' },
90
+ * ],
91
+ * toDOM() {
92
+ * return ['strong', 0]
93
+ * },
94
+ * })
95
+ * ```
80
96
  */
81
97
  export function defineMarkSpec<
82
98
  Mark extends string,
@@ -133,35 +149,32 @@ const markSpecFacet = defineFacet<MarkSpecPayload, SchemaSpec>({
133
149
  }
134
150
  }
135
151
 
136
- const groupedAttrs = groupBy(attrPayloads, (payload) => payload.type)
152
+ const groupedAttrs = mapGroupBy(attrPayloads, (payload) => payload.type)
137
153
 
138
- for (const [type, attrs] of Object.entries(groupedAttrs)) {
154
+ for (const [type, attrs] of groupedAttrs.entries()) {
139
155
  if (!attrs) continue
140
156
 
141
- const maybeSpec = specs.get(type)
142
- assert(maybeSpec, `Mark type ${type} must be defined`)
143
- const spec = clone(maybeSpec)
157
+ const oldSpec = specs.get(type)
158
+ assert(oldSpec, `Mark type ${type} must be defined`)
144
159
 
145
- if (!spec.attrs) {
146
- spec.attrs = {}
147
- }
160
+ const newSpec = { ...oldSpec, attrs: { ...oldSpec.attrs } } satisfies MarkSpec
148
161
 
149
162
  for (const attr of attrs) {
150
- spec.attrs[attr.attr] = {
163
+ newSpec.attrs[attr.attr] = {
151
164
  default: attr.default as unknown,
152
165
  validate: attr.validate,
153
- }
166
+ } satisfies AttributeSpec
154
167
  }
155
168
 
156
- if (spec.toDOM) {
157
- spec.toDOM = wrapOutputSpecAttrs(spec.toDOM, attrs)
169
+ if (oldSpec.toDOM) {
170
+ newSpec.toDOM = wrapOutputSpecAttrs(oldSpec.toDOM, attrs)
158
171
  }
159
172
 
160
- if (spec.parseDOM) {
161
- spec.parseDOM = spec.parseDOM.map((rule) => wrapParseRuleAttrs(rule, attrs))
173
+ if (oldSpec.parseDOM) {
174
+ newSpec.parseDOM = oldSpec.parseDOM.map((rule) => wrapParseRuleAttrs(rule, attrs))
162
175
  }
163
176
 
164
- specs = specs.update(type, spec)
177
+ specs = specs.update(type, newSpec)
165
178
  }
166
179
 
167
180
  return { marks: specs, nodes: {} }
@@ -169,13 +182,3 @@ const markSpecFacet = defineFacet<MarkSpecPayload, SchemaSpec>({
169
182
  parent: schemaSpecFacet,
170
183
  singleton: true,
171
184
  })
172
-
173
- function wrapParseRuleAttrs(
174
- rule: ParseRule,
175
- attrs: MarkAttrOptions[],
176
- ): ParseRule {
177
- if (rule.tag) {
178
- return wrapTagParseRuleAttrs(rule, attrs)
179
- }
180
- return rule
181
- }
@@ -1,9 +1,9 @@
1
+ import { mapGroupBy } from '@ocavue/utils'
1
2
  import type {
2
3
  AttributeSpec,
3
4
  NodeSpec,
4
5
  SchemaSpec,
5
6
  } from '@prosekit/pm/model'
6
- import clone from 'just-clone'
7
7
  import OrderedMap from 'orderedmap'
8
8
 
9
9
  import { defineFacet } from '../facets/facet'
@@ -14,7 +14,6 @@ import type {
14
14
  AttrSpec,
15
15
  } from '../types/attrs'
16
16
  import type { Extension } from '../types/extension'
17
- import { groupBy } from '../utils/array-grouping'
18
17
  import { assert } from '../utils/assert'
19
18
  import { mergeSpecs } from '../utils/merge-specs'
20
19
  import {
@@ -93,9 +92,23 @@ export interface NodeAttrOptions<
93
92
  }
94
93
 
95
94
  /**
96
- * Defines a node type.
95
+ * Defines a node type into the editor schema.
97
96
  *
98
97
  * @public
98
+ *
99
+ * @example
100
+ *
101
+ * ```ts
102
+ * const extension = defineNodeSpec({
103
+ * name: 'fancyParagraph',
104
+ * content: 'inline*',
105
+ * group: 'block',
106
+ * parseDOM: [{ tag: 'p.fancy' }],
107
+ * toDOM() {
108
+ * return ['p', { 'class': 'fancy' }, 0]
109
+ * },
110
+ * })
111
+ * ```
99
112
  */
100
113
  export function defineNodeSpec<
101
114
  Node extends string,
@@ -159,37 +172,33 @@ const nodeSpecFacet = defineFacet<NodeSpecPayload, SchemaSpec>({
159
172
  }
160
173
  }
161
174
 
162
- const groupedAttrs = groupBy(attrPayloads, (payload) => payload.type)
175
+ const groupedAttrs = mapGroupBy(attrPayloads, (payload) => payload.type)
163
176
 
164
- for (const [type, attrs] of Object.entries(groupedAttrs)) {
177
+ for (const [type, attrs] of groupedAttrs.entries()) {
165
178
  if (!attrs) continue
166
179
 
167
- const maybeSpec = specs.get(type)
168
- assert(maybeSpec, `Node type ${type} must be defined`)
180
+ const oldSpec = specs.get(type)
181
+ assert(oldSpec, `Node type ${type} must be defined`)
169
182
 
170
- const spec = clone(maybeSpec)
171
-
172
- if (!spec.attrs) {
173
- spec.attrs = {}
174
- }
183
+ const newSpec = { ...oldSpec, attrs: { ...oldSpec.attrs } } satisfies NodeSpec
175
184
 
176
185
  for (const attr of attrs) {
177
- spec.attrs[attr.attr] = {
186
+ newSpec.attrs[attr.attr] = {
178
187
  default: attr.default as unknown,
179
188
  validate: attr.validate,
180
189
  splittable: attr.splittable,
181
- } as AttributeSpec
190
+ } satisfies AttributeSpec
182
191
  }
183
192
 
184
- if (spec.toDOM) {
185
- spec.toDOM = wrapOutputSpecAttrs(spec.toDOM, attrs)
193
+ if (oldSpec.toDOM) {
194
+ newSpec.toDOM = wrapOutputSpecAttrs(oldSpec.toDOM, attrs)
186
195
  }
187
196
 
188
- if (spec.parseDOM) {
189
- spec.parseDOM = spec.parseDOM.map((rule) => wrapTagParseRuleAttrs(rule, attrs))
197
+ if (oldSpec.parseDOM) {
198
+ newSpec.parseDOM = oldSpec.parseDOM.map((rule) => wrapTagParseRuleAttrs(rule, attrs))
190
199
  }
191
200
 
192
- specs = specs.update(type, spec)
201
+ specs = specs.update(type, newSpec)
193
202
  }
194
203
 
195
204
  return { nodes: specs, topNode: topNodeName }
@@ -15,7 +15,6 @@ import {
15
15
  type StatePayload,
16
16
  } from '../facets/state'
17
17
  import type { PlainExtension } from '../types/extension'
18
- import { toReversed } from '../utils/array'
19
18
 
20
19
  /**
21
20
  * Adds a ProseMirror plugin to the editor.
@@ -72,7 +71,7 @@ export const pluginFacet: Facet<PluginPayload, StatePayload> = defineFacet({
72
71
 
73
72
  // An array of plugins from higher to lower priority. This matches the
74
73
  // order of plugins required by ProseMirror.
75
- const reversedPlugins = toReversed(plugins)
74
+ const reversedPlugins = [...plugins].reverse()
76
75
 
77
76
  return { plugins: reversedPlugins }
78
77
  }
@@ -13,8 +13,14 @@ type CommandPayload = CommandCreators
13
13
 
14
14
  export const commandFacet: Facet<CommandPayload, RootPayload> = defineFacet({
15
15
  reducer: (inputs) => {
16
- const commands = Object.assign({}, ...inputs) as CommandPayload
17
- return { commands }
16
+ switch (inputs.length) {
17
+ case 0:
18
+ return { commands: {} }
19
+ case 1:
20
+ return { commands: inputs[0] }
21
+ default:
22
+ return { commands: Object.assign({}, ...inputs) as CommandCreators }
23
+ }
18
24
  },
19
25
  parent: rootFacet,
20
26
  singleton: true,
@@ -20,9 +20,9 @@ describe('state', () => {
20
20
  const doc2: NodeJSON = { type: 'doc', content: [{ type: 'paragraph', content: [{ type: 'text', text: 'highest priority' }] }] }
21
21
  const doc3: NodeJSON = { type: 'doc', content: [{ type: 'paragraph', content: [{ type: 'text', text: 'lowest priority' }] }] }
22
22
 
23
- const extension1 = defineDefaultState({ defaultDoc: doc1 }) // default priority
24
- const extension2 = withPriority(defineDefaultState({ defaultDoc: doc2 }), Priority.highest)
25
- const extension3 = withPriority(defineDefaultState({ defaultDoc: doc3 }), Priority.lowest)
23
+ const extension1 = defineDefaultState({ defaultContent: doc1 }) // default priority
24
+ const extension2 = withPriority(defineDefaultState({ defaultContent: doc2 }), Priority.highest)
25
+ const extension3 = withPriority(defineDefaultState({ defaultContent: doc3 }), Priority.lowest)
26
26
 
27
27
  const combinedExtension = union(defineTestExtension(), extension1, extension2, extension3)
28
28
  const { editor } = setupTestFromExtension(combinedExtension)
@@ -38,9 +38,9 @@ describe('state', () => {
38
38
  const doc2 = { type: 'doc', content: [{ type: 'paragraph', content: [{ type: 'text', text: 'second' }] }] }
39
39
  const doc3 = { type: 'doc', content: [{ type: 'paragraph', content: [{ type: 'text', text: 'third' }] }] }
40
40
 
41
- const extension1 = defineDefaultState({ defaultDoc: doc1 })
42
- const extension2 = defineDefaultState({ defaultDoc: doc2 })
43
- const extension3 = defineDefaultState({ defaultDoc: doc3 })
41
+ const extension1 = defineDefaultState({ defaultContent: doc1 })
42
+ const extension2 = defineDefaultState({ defaultContent: doc2 })
43
+ const extension3 = defineDefaultState({ defaultContent: doc3 })
44
44
 
45
45
  const combinedExtension = union(defineTestExtension(), extension1, extension2, extension3)
46
46
  const { editor } = setupTestFromExtension(combinedExtension)
@@ -9,7 +9,6 @@ import type {
9
9
  Selection,
10
10
  } from '@prosekit/pm/state'
11
11
 
12
- import { toReversed } from '../utils/array'
13
12
  import { assert } from '../utils/assert'
14
13
 
15
14
  import {
@@ -37,7 +36,7 @@ export const stateFacet: Facet<StatePayload, RootPayload> = defineFacet({
37
36
 
38
37
  // An array of state payloads from higher to lower priority. This matches the
39
38
  // order of plugins required by ProseMirror.
40
- const reversedCallbacks = toReversed(callbacks)
39
+ const reversedCallbacks = [...callbacks].reverse()
41
40
 
42
41
  for (const callback of reversedCallbacks) {
43
42
  const config = callback(ctx)
package/src/index.ts CHANGED
@@ -22,6 +22,8 @@ export {
22
22
  removeNode,
23
23
  type RemoveNodeOptions,
24
24
  } from './commands/remove-node'
25
+ export { selectAll } from './commands/select-all'
26
+ export { selectBlock } from './commands/select-block'
25
27
  export {
26
28
  setBlockType,
27
29
  type SetBlockTypeOptions,
@@ -56,9 +58,7 @@ export {
56
58
  } from './commands/wrap'
57
59
  export type {
58
60
  MarkAction,
59
- MarkBuilder,
60
61
  NodeAction,
61
- NodeBuilder,
62
62
  NodeChild,
63
63
  } from './editor/action'
64
64
  export {
@@ -85,10 +85,6 @@ export {
85
85
  defineDefaultState,
86
86
  type DefaultStateOptions,
87
87
  } from './extensions/default-state'
88
- export {
89
- defineDoc,
90
- type DocExtension,
91
- } from './extensions/doc'
92
88
  export {
93
89
  defineDocChangeHandler,
94
90
  type DocChangeHandler,
@@ -151,6 +147,7 @@ export {
151
147
  export {
152
148
  defineBaseKeymap,
153
149
  type BaseKeymapExtension,
150
+ type BaseKeymapOptions,
154
151
  } from './extensions/keymap-base'
155
152
  export {
156
153
  defineMarkAttr,
@@ -184,19 +181,11 @@ export {
184
181
  type NodeViewComponentOptions,
185
182
  type NodeViewFactoryOptions,
186
183
  } from './extensions/node-view-effect'
187
- export {
188
- defineParagraph,
189
- type ParagraphExtension,
190
- } from './extensions/paragraph'
191
184
  export {
192
185
  definePlugin,
193
186
  pluginFacet,
194
187
  type PluginPayload,
195
188
  } from './extensions/plugin'
196
- export {
197
- defineText,
198
- type TextExtension,
199
- } from './extensions/text'
200
189
  export {
201
190
  defineFacet,
202
191
  type Facet,
@@ -207,12 +196,10 @@ export type {
207
196
  AnyAttrs,
208
197
  AttrSpec,
209
198
  } from './types/attrs'
210
- export type { BaseNodeViewOptions } from './types/base-node-view-options'
211
199
  export type {
212
200
  Extension,
213
201
  ExtensionTyping,
214
202
  ExtractCommandActions,
215
- ExtractCommandAppliers,
216
203
  ExtractCommandCreators,
217
204
  ExtractCommands,
218
205
  ExtractMarkActions,
@@ -222,7 +209,6 @@ export type {
222
209
  ExtractTyping,
223
210
  PlainExtension,
224
211
  Union,
225
- UnionExtension,
226
212
  } from './types/extension'
227
213
  export type {
228
214
  CommandAction,
@@ -249,11 +235,6 @@ export type { SimplifyUnion } from './types/simplify-union'
249
235
  export { assert } from './utils/assert'
250
236
  export { canUseRegexLookbehind } from './utils/can-use-regex-lookbehind'
251
237
  export { clsx } from './utils/clsx'
252
- export { collectChildren } from './utils/collect-children'
253
- export {
254
- collectNodes,
255
- type NodeContent,
256
- } from './utils/collect-nodes'
257
238
  export { containsInlineNode } from './utils/contains-inline-node'
258
239
  export { defaultBlockAt } from './utils/default-block-at'
259
240
  export { isApple } from './utils/env'
@@ -262,7 +243,6 @@ export {
262
243
  type FindParentNodeResult,
263
244
  } from './utils/find-parent-node'
264
245
  export { findParentNodeOfType } from './utils/find-parent-node-of-type'
265
- export { getId as _getId } from './utils/get-id'
266
246
  export { getMarkType } from './utils/get-mark-type'
267
247
  export { getNodeType } from './utils/get-node-type'
268
248
  export { isAtBlockStart } from './utils/is-at-block-start'
@@ -19,13 +19,6 @@ export interface CommandAction<Args extends any[] = any[]> {
19
19
  * can be executed, otherwise `false`.
20
20
  */
21
21
  canExec(...args: Args): boolean
22
-
23
- /**
24
- * An alias for `canExec`.
25
- *
26
- * @deprecated Use `canExec` instead.
27
- */
28
- canApply(...args: Args): boolean
29
22
  }
30
23
 
31
24
  export type CommandCreator<Args extends any[] = any[]> = (