@prosekit/core 0.10.0 → 0.12.0-beta.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 (132) hide show
  1. package/dist/{editor-BULC1zqX.d.ts → editor.d.ts} +48 -8
  2. package/dist/editor.d.ts.map +1 -0
  3. package/dist/{editor-g-Rqn-ZE.js → editor.js} +19 -60
  4. package/dist/editor.js.map +1 -0
  5. package/dist/prosekit-core-test.d.ts +1 -1
  6. package/dist/prosekit-core-test.js +2 -4
  7. package/dist/prosekit-core-test.js.map +1 -1
  8. package/dist/prosekit-core.d.ts +69 -68
  9. package/dist/prosekit-core.d.ts.map +1 -1
  10. package/dist/prosekit-core.js +100 -135
  11. package/dist/prosekit-core.js.map +1 -1
  12. package/package.json +6 -5
  13. package/src/commands/add-mark.ts +2 -2
  14. package/src/commands/expand-mark.ts +1 -1
  15. package/src/commands/insert-default-block.spec.ts +3 -3
  16. package/src/commands/insert-default-block.ts +1 -1
  17. package/src/commands/insert-node.ts +3 -3
  18. package/src/commands/remove-mark.ts +2 -2
  19. package/src/commands/remove-node.ts +2 -2
  20. package/src/commands/select-block.spec.ts +2 -2
  21. package/src/commands/select-block.ts +1 -1
  22. package/src/commands/set-block-type.ts +2 -2
  23. package/src/commands/set-node-attrs-between.spec.ts +2 -2
  24. package/src/commands/set-node-attrs-between.ts +1 -1
  25. package/src/commands/set-node-attrs.spec.ts +2 -2
  26. package/src/commands/set-node-attrs.ts +2 -2
  27. package/src/commands/toggle-mark.ts +2 -2
  28. package/src/commands/toggle-node.ts +2 -2
  29. package/src/commands/toggle-wrap.spec.ts +1 -1
  30. package/src/commands/toggle-wrap.ts +2 -2
  31. package/src/commands/unset-block-type.spec.ts +1 -1
  32. package/src/commands/unset-block-type.ts +1 -1
  33. package/src/commands/unset-mark.spec.ts +1 -1
  34. package/src/commands/unset-mark.ts +1 -1
  35. package/src/commands/wrap.ts +1 -1
  36. package/src/editor/action.spec.ts +3 -3
  37. package/src/editor/action.ts +6 -6
  38. package/src/editor/editor.spec.ts +5 -5
  39. package/src/editor/editor.ts +13 -13
  40. package/src/editor/union.spec.ts +7 -7
  41. package/src/editor/union.ts +4 -4
  42. package/src/editor/with-priority.ts +3 -3
  43. package/src/error.ts +8 -1
  44. package/src/extensions/clipboard-serializer.ts +17 -9
  45. package/src/extensions/command.ts +19 -19
  46. package/src/extensions/default-state.spec.ts +3 -3
  47. package/src/extensions/default-state.ts +5 -5
  48. package/src/extensions/events/doc-change.ts +2 -2
  49. package/src/extensions/events/dom-event.spec.ts +3 -3
  50. package/src/extensions/events/dom-event.ts +7 -7
  51. package/src/extensions/events/editor-event.ts +6 -6
  52. package/src/extensions/events/focus.spec.ts +4 -4
  53. package/src/extensions/events/focus.ts +2 -2
  54. package/src/extensions/events/plugin-view.ts +4 -4
  55. package/src/extensions/history.ts +6 -6
  56. package/src/extensions/keymap-base.spec.ts +5 -5
  57. package/src/extensions/keymap-base.ts +6 -6
  58. package/src/extensions/keymap.spec.ts +5 -5
  59. package/src/extensions/keymap.ts +4 -4
  60. package/src/extensions/mark-spec.spec.ts +3 -3
  61. package/src/extensions/mark-spec.ts +8 -8
  62. package/src/extensions/mark-view-effect.ts +4 -4
  63. package/src/extensions/mark-view.ts +4 -4
  64. package/src/extensions/node-spec.spec.ts +5 -5
  65. package/src/extensions/node-spec.ts +8 -8
  66. package/src/extensions/node-view-effect.ts +4 -4
  67. package/src/extensions/node-view.ts +4 -4
  68. package/src/extensions/plugin.spec.ts +5 -5
  69. package/src/extensions/plugin.ts +5 -5
  70. package/src/facets/base-extension.ts +7 -7
  71. package/src/facets/command.ts +3 -3
  72. package/src/facets/facet-extension.spec.ts +6 -6
  73. package/src/facets/facet-extension.ts +12 -8
  74. package/src/facets/facet-node.spec.ts +3 -3
  75. package/src/facets/facet-node.ts +24 -14
  76. package/src/facets/facet.spec.ts +1 -1
  77. package/src/facets/facet.ts +14 -7
  78. package/src/facets/root.ts +2 -2
  79. package/src/facets/schema-spec.ts +2 -2
  80. package/src/facets/schema.ts +3 -3
  81. package/src/facets/state.spec.ts +6 -6
  82. package/src/facets/state.ts +3 -3
  83. package/src/facets/union-extension.ts +9 -6
  84. package/src/index.ts +74 -74
  85. package/src/test/index.ts +1 -1
  86. package/src/test/test-builder.ts +2 -2
  87. package/src/test/test-editor.spec.ts +1 -1
  88. package/src/test/test-editor.ts +6 -6
  89. package/src/testing/index.ts +10 -10
  90. package/src/types/extension-mark.ts +1 -1
  91. package/src/types/extension-node.ts +1 -1
  92. package/src/types/extension.spec.ts +2 -2
  93. package/src/types/extension.ts +8 -8
  94. package/src/types/pick-string-literal.spec.ts +2 -2
  95. package/src/types/pick-string-literal.ts +1 -1
  96. package/src/types/pick-sub-type.spec.ts +2 -2
  97. package/src/types/priority.ts +50 -7
  98. package/src/types/simplify-deeper.spec.ts +2 -2
  99. package/src/types/simplify-union.spec.ts +2 -2
  100. package/src/utils/array-grouping.spec.ts +1 -1
  101. package/src/utils/assert.ts +1 -1
  102. package/src/utils/can-use-regex-lookbehind.ts +2 -8
  103. package/src/utils/clsx.spec.ts +1 -1
  104. package/src/utils/combine-event-handlers.spec.ts +1 -1
  105. package/src/utils/editor-content.spec.ts +2 -2
  106. package/src/utils/editor-content.ts +4 -4
  107. package/src/utils/find-parent-node-of-type.ts +2 -2
  108. package/src/utils/find-parent-node.spec.ts +2 -2
  109. package/src/utils/get-dom-api.ts +1 -1
  110. package/src/utils/get-mark-type.ts +1 -1
  111. package/src/utils/get-node-type.ts +1 -1
  112. package/src/utils/get-node-types.ts +1 -1
  113. package/src/utils/includes-mark.ts +1 -1
  114. package/src/utils/is-mark-absent.spec.ts +2 -2
  115. package/src/utils/is-mark-absent.ts +1 -1
  116. package/src/utils/is-mark-active.ts +3 -3
  117. package/src/utils/is-node-active.spec.ts +2 -2
  118. package/src/utils/is-node-active.ts +3 -3
  119. package/src/utils/is-subset.spec.ts +1 -1
  120. package/src/utils/maybe-run.spec.ts +1 -1
  121. package/src/utils/merge-objects.spec.ts +1 -1
  122. package/src/utils/merge-objects.ts +1 -1
  123. package/src/utils/merge-specs.ts +1 -1
  124. package/src/utils/object-equal.spec.ts +1 -1
  125. package/src/utils/output-spec.test.ts +1 -1
  126. package/src/utils/parse.spec.ts +3 -3
  127. package/src/utils/parse.ts +3 -3
  128. package/src/utils/remove-undefined-values.spec.ts +1 -1
  129. package/src/utils/unicode.spec.ts +1 -1
  130. package/src/utils/with-skip-code-block.ts +1 -1
  131. package/dist/editor-BULC1zqX.d.ts.map +0 -1
  132. package/dist/editor-g-Rqn-ZE.js.map +0 -1
@@ -2,9 +2,9 @@ import type { Schema } from '@prosekit/pm/model'
2
2
  import type { EditorStateConfig } from '@prosekit/pm/state'
3
3
  import type { DirectEditorProps } from '@prosekit/pm/view'
4
4
 
5
- import type { CommandCreators } from '../types/extension-command'
5
+ import type { CommandCreators } from '../types/extension-command.ts'
6
6
 
7
- import { Facet } from './facet'
7
+ import { Facet } from './facet.ts'
8
8
 
9
9
  export type RootPayload = {
10
10
  schema?: Schema | null
@@ -1,8 +1,8 @@
1
1
  import type { MarkSpec, NodeSpec, SchemaSpec } from '@prosekit/pm/model'
2
2
  import OrderedMap from 'orderedmap'
3
3
 
4
- import { defineFacet, type Facet } from './facet'
5
- import { schemaFacet } from './schema'
4
+ import { defineFacet, type Facet } from './facet.ts'
5
+ import { schemaFacet } from './schema.ts'
6
6
 
7
7
  export const schemaSpecFacet: Facet<SchemaSpec, SchemaSpec> = defineFacet({
8
8
  reducer: (specs): SchemaSpec => {
@@ -1,9 +1,9 @@
1
1
  import { Schema, type SchemaSpec } from '@prosekit/pm/model'
2
2
 
3
- import { assert } from '../utils/assert'
3
+ import { assert } from '../utils/assert.ts'
4
4
 
5
- import { defineFacet, type Facet } from './facet'
6
- import { rootFacet, type RootPayload } from './root'
5
+ import { defineFacet, type Facet } from './facet.ts'
6
+ import { rootFacet, type RootPayload } from './root.ts'
7
7
 
8
8
  export const schemaFacet: Facet<SchemaSpec, RootPayload> = defineFacet({
9
9
  reducer: (specs) => {
@@ -1,11 +1,11 @@
1
1
  import { describe, expect, it } from 'vitest'
2
2
 
3
- import { union } from '../editor/union'
4
- import { withPriority } from '../editor/with-priority'
5
- import { defineDefaultState } from '../extensions/default-state'
6
- import { defineTestExtension, setupTestFromExtension } from '../testing'
7
- import type { NodeJSON } from '../types/model'
8
- import { Priority } from '../types/priority'
3
+ import { union } from '../editor/union.ts'
4
+ import { withPriority } from '../editor/with-priority.ts'
5
+ import { defineDefaultState } from '../extensions/default-state.ts'
6
+ import { defineTestExtension, setupTestFromExtension } from '../testing/index.ts'
7
+ import type { NodeJSON } from '../types/model.ts'
8
+ import { Priority } from '../types/priority.ts'
9
9
 
10
10
  describe('state', () => {
11
11
  it('uses doc from extension with highest priority', () => {
@@ -1,10 +1,10 @@
1
1
  import type { Mark, ProseMirrorNode, Schema } from '@prosekit/pm/model'
2
2
  import type { EditorStateConfig, Plugin, Selection } from '@prosekit/pm/state'
3
3
 
4
- import { assert } from '../utils/assert'
4
+ import { assert } from '../utils/assert.ts'
5
5
 
6
- import { defineFacet, type Facet } from './facet'
7
- import { rootFacet, type RootPayload } from './root'
6
+ import { defineFacet, type Facet } from './facet.ts'
7
+ import { rootFacet, type RootPayload } from './root.ts'
8
8
 
9
9
  export type StatePayload = (ctx: { schema: Schema }) => EditorStateConfig
10
10
 
@@ -1,16 +1,19 @@
1
- import type { Extension, ExtensionTyping } from '../types/extension'
2
- import type { Priority } from '../types/priority'
3
- import { assert } from '../utils/assert'
1
+ import type { Extension, ExtensionTyping } from '../types/extension.ts'
2
+ import type { Priority } from '../types/priority.ts'
3
+ import { assert } from '../utils/assert.ts'
4
4
 
5
- import { BaseExtension } from './base-extension'
6
- import { unionFacetNode, type FacetNode } from './facet-node'
5
+ import { BaseExtension } from './base-extension.ts'
6
+ import { unionFacetNode, type FacetNode } from './facet-node.ts'
7
7
 
8
8
  export class UnionExtensionImpl<T extends ExtensionTyping = ExtensionTyping> extends BaseExtension<T> implements Extension<T> {
9
+ readonly extension: BaseExtension[]
10
+
9
11
  /**
10
12
  * @internal
11
13
  */
12
- constructor(public extension: BaseExtension[] = []) {
14
+ constructor(extension: BaseExtension[] = []) {
13
15
  super()
16
+ this.extension = extension
14
17
  }
15
18
 
16
19
  /**
package/src/index.ts CHANGED
@@ -1,30 +1,30 @@
1
- export { addMark, type AddMarkOptions } from './commands/add-mark'
2
- export { expandMark, type ExpandMarkOptions } from './commands/expand-mark'
3
- export { insertDefaultBlock, type InsertDefaultBlockOptions } from './commands/insert-default-block'
4
- export { insertNode, type InsertNodeOptions } from './commands/insert-node'
5
- export { removeMark, type RemoveMarkOptions } from './commands/remove-mark'
6
- export { removeNode, type RemoveNodeOptions } from './commands/remove-node'
7
- export { selectAll } from './commands/select-all'
8
- export { selectBlock } from './commands/select-block'
9
- export { setBlockType, type SetBlockTypeOptions } from './commands/set-block-type'
10
- export { setNodeAttrs, type SetNodeAttrsOptions } from './commands/set-node-attrs'
11
- export { setNodeAttrsBetween, type SetNodeAttrsBetweenOptions } from './commands/set-node-attrs-between'
12
- export { toggleMark, type ToggleMarkOptions } from './commands/toggle-mark'
13
- export { toggleNode, type ToggleNodeOptions } from './commands/toggle-node'
14
- export { toggleWrap, type ToggleWrapOptions } from './commands/toggle-wrap'
15
- export { unsetBlockType, type UnsetBlockTypeOptions } from './commands/unset-block-type'
16
- export { unsetMark, type UnsetMarkOptions } from './commands/unset-mark'
17
- export { wrap, type WrapOptions } from './commands/wrap'
18
- export type { MarkAction, NodeAction, NodeChild } from './editor/action'
19
- export { createEditor, Editor, type EditorOptions } from './editor/editor'
20
- export { union } from './editor/union'
21
- export { withPriority } from './editor/with-priority'
22
- export { EditorNotFoundError, ProseKitError } from './error'
23
- export { defineClipboardSerializer, type ClipboardSerializerOptions } from './extensions/clipboard-serializer'
24
- export { defineBaseCommands, defineCommands, type BaseCommandsExtension } from './extensions/command'
25
- export { defineDefaultState, type DefaultStateOptions } from './extensions/default-state'
26
- export { defineDocChangeHandler, type DocChangeHandler } from './extensions/events/doc-change'
27
- export { defineDOMEventHandler, type DOMEventHandler } from './extensions/events/dom-event'
1
+ export { addMark, type AddMarkOptions } from './commands/add-mark.ts'
2
+ export { expandMark, type ExpandMarkOptions } from './commands/expand-mark.ts'
3
+ export { insertDefaultBlock, type InsertDefaultBlockOptions } from './commands/insert-default-block.ts'
4
+ export { insertNode, type InsertNodeOptions } from './commands/insert-node.ts'
5
+ export { removeMark, type RemoveMarkOptions } from './commands/remove-mark.ts'
6
+ export { removeNode, type RemoveNodeOptions } from './commands/remove-node.ts'
7
+ export { selectAll } from './commands/select-all.ts'
8
+ export { selectBlock } from './commands/select-block.ts'
9
+ export { setBlockType, type SetBlockTypeOptions } from './commands/set-block-type.ts'
10
+ export { setNodeAttrsBetween, type SetNodeAttrsBetweenOptions } from './commands/set-node-attrs-between.ts'
11
+ export { setNodeAttrs, type SetNodeAttrsOptions } from './commands/set-node-attrs.ts'
12
+ export { toggleMark, type ToggleMarkOptions } from './commands/toggle-mark.ts'
13
+ export { toggleNode, type ToggleNodeOptions } from './commands/toggle-node.ts'
14
+ export { toggleWrap, type ToggleWrapOptions } from './commands/toggle-wrap.ts'
15
+ export { unsetBlockType, type UnsetBlockTypeOptions } from './commands/unset-block-type.ts'
16
+ export { unsetMark, type UnsetMarkOptions } from './commands/unset-mark.ts'
17
+ export { wrap, type WrapOptions } from './commands/wrap.ts'
18
+ export type { MarkAction, NodeAction, NodeChild } from './editor/action.ts'
19
+ export { createEditor, Editor, type EditorOptions } from './editor/editor.ts'
20
+ export { union } from './editor/union.ts'
21
+ export { withPriority } from './editor/with-priority.ts'
22
+ export { EditorNotFoundError, ProseKitError } from './error.ts'
23
+ export { defineClipboardSerializer, type ClipboardSerializerOptions } from './extensions/clipboard-serializer.ts'
24
+ export { defineBaseCommands, defineCommands, type BaseCommandsExtension } from './extensions/command.ts'
25
+ export { defineDefaultState, type DefaultStateOptions } from './extensions/default-state.ts'
26
+ export { defineDocChangeHandler, type DocChangeHandler } from './extensions/events/doc-change.ts'
27
+ export { defineDOMEventHandler, type DOMEventHandler } from './extensions/events/dom-event.ts'
28
28
  export {
29
29
  defineClickHandler,
30
30
  defineClickOnHandler,
@@ -52,8 +52,8 @@ export {
52
52
  type TextInputHandler,
53
53
  type TripleClickHandler,
54
54
  type TripleClickOnHandler,
55
- } from './extensions/events/editor-event'
56
- export { defineFocusChangeHandler, type FocusChangeHandler } from './extensions/events/focus'
55
+ } from './extensions/events/editor-event.ts'
56
+ export { defineFocusChangeHandler, type FocusChangeHandler } from './extensions/events/focus.ts'
57
57
  export {
58
58
  defineMountHandler,
59
59
  defineUnmountHandler,
@@ -61,31 +61,34 @@ export {
61
61
  type MountHandler,
62
62
  type UnmountHandler,
63
63
  type UpdateHandler,
64
- } from './extensions/events/plugin-view'
65
- export { defineHistory, type HistoryExtension, type HistoryOptions } from './extensions/history'
66
- export { defineKeymap, keymapFacet, type Keymap, type KeymapPayload } from './extensions/keymap'
67
- export { defineBaseKeymap, type BaseKeymapExtension, type BaseKeymapOptions } from './extensions/keymap-base'
68
- export { defineMarkAttr, defineMarkSpec, type MarkAttrOptions, type MarkSpecOptions } from './extensions/mark-spec'
69
- export { defineMarkView, type MarkViewOptions } from './extensions/mark-view'
64
+ } from './extensions/events/plugin-view.ts'
65
+ export { defineHistory, type HistoryExtension, type HistoryOptions } from './extensions/history.ts'
66
+ export { defineBaseKeymap, type BaseKeymapExtension, type BaseKeymapOptions } from './extensions/keymap-base.ts'
67
+ export { defineKeymap, keymapFacet, type Keymap, type KeymapPayload } from './extensions/keymap.ts'
68
+ export { defineMarkAttr, defineMarkSpec, type MarkAttrOptions, type MarkSpecOptions } from './extensions/mark-spec.ts'
70
69
  export {
71
70
  defineMarkViewComponent,
72
71
  defineMarkViewFactory,
73
72
  type MarkViewComponentOptions,
74
73
  type MarkViewFactoryOptions,
75
- } from './extensions/mark-view-effect'
76
- export { defineNodeAttr, defineNodeSpec, type NodeAttrOptions, type NodeSpecOptions } from './extensions/node-spec'
77
- export { defineNodeView, type NodeViewOptions } from './extensions/node-view'
74
+ } from './extensions/mark-view-effect.ts'
75
+ export { defineMarkView, type MarkViewOptions } from './extensions/mark-view.ts'
76
+ export { defineNodeAttr, defineNodeSpec, type NodeAttrOptions, type NodeSpecOptions } from './extensions/node-spec.ts'
78
77
  export {
79
78
  defineNodeViewComponent,
80
79
  defineNodeViewFactory,
81
80
  type NodeViewComponentOptions,
82
81
  type NodeViewFactoryOptions,
83
- } from './extensions/node-view-effect'
84
- export { definePlugin, pluginFacet, type PluginPayload } from './extensions/plugin'
85
- export { defineFacet, type Facet } from './facets/facet'
86
- export { defineFacetPayload } from './facets/facet-extension'
87
- export type { AnyFunction } from './types/any-function'
88
- export type { AnyAttrs, AttrSpec } from './types/attrs'
82
+ } from './extensions/node-view-effect.ts'
83
+ export { defineNodeView, type NodeViewOptions } from './extensions/node-view.ts'
84
+ export { definePlugin, pluginFacet, type PluginPayload } from './extensions/plugin.ts'
85
+ export { defineFacetPayload } from './facets/facet-extension.ts'
86
+ export { defineFacet, type Facet } from './facets/facet.ts'
87
+ export type { AnyFunction } from './types/any-function.ts'
88
+ export type { AnyAttrs, AttrSpec } from './types/attrs.ts'
89
+ export type { CommandAction, CommandTyping } from './types/extension-command.ts'
90
+ export type { MarkTyping, ToMarkAction } from './types/extension-mark.ts'
91
+ export type { NodeTyping, ToNodeAction } from './types/extension-node.ts'
89
92
  export type {
90
93
  Extension,
91
94
  ExtensionTyping,
@@ -99,31 +102,28 @@ export type {
99
102
  ExtractTyping,
100
103
  PlainExtension,
101
104
  Union,
102
- } from './types/extension'
103
- export type { CommandAction, CommandTyping } from './types/extension-command'
104
- export type { MarkTyping, ToMarkAction } from './types/extension-mark'
105
- export type { NodeTyping, ToNodeAction } from './types/extension-node'
106
- export type { NodeJSON, SelectionJSON, StateJSON, StepJSON } from './types/model'
107
- export type { PickSubType } from './types/pick-sub-type'
108
- export { Priority } from './types/priority'
109
- export type { SimplifyDeeper } from './types/simplify-deeper'
110
- export type { SimplifyUnion } from './types/simplify-union'
111
- export { assert } from './utils/assert'
112
- export { canUseRegexLookbehind } from './utils/can-use-regex-lookbehind'
113
- export { clsx } from './utils/clsx'
114
- export { containsInlineNode } from './utils/contains-inline-node'
115
- export { defaultBlockAt } from './utils/default-block-at'
116
- export { isApple } from './utils/env'
117
- export { findNode, findNodes, type FindNodeResult } from './utils/find-node'
118
- export { findParentNode, type FindParentNodeResult } from './utils/find-parent-node'
119
- export { findParentNodeOfType } from './utils/find-parent-node-of-type'
120
- export { getMarkType } from './utils/get-mark-type'
121
- export { getNodeType } from './utils/get-node-type'
122
- export { isAtBlockStart } from './utils/is-at-block-start'
123
- export { isInCodeBlock } from './utils/is-in-code-block'
124
- export { isMarkAbsent } from './utils/is-mark-absent'
125
- export { isMarkActive } from './utils/is-mark-active'
126
- export { maybeRun } from './utils/maybe-run'
105
+ } from './types/extension.ts'
106
+ export type { NodeJSON, SelectionJSON, StateJSON, StepJSON } from './types/model.ts'
107
+ export type { PickSubType } from './types/pick-sub-type.ts'
108
+ export { Priority } from './types/priority.ts'
109
+ export type { SimplifyDeeper } from './types/simplify-deeper.ts'
110
+ export type { SimplifyUnion } from './types/simplify-union.ts'
111
+ export { assert } from './utils/assert.ts'
112
+ export { canUseRegexLookbehind } from './utils/can-use-regex-lookbehind.ts'
113
+ export { clsx } from './utils/clsx.ts'
114
+ export { containsInlineNode } from './utils/contains-inline-node.ts'
115
+ export { defaultBlockAt } from './utils/default-block-at.ts'
116
+ export { isApple } from './utils/env.ts'
117
+ export { findNode, findNodes, type FindNodeResult } from './utils/find-node.ts'
118
+ export { findParentNodeOfType } from './utils/find-parent-node-of-type.ts'
119
+ export { findParentNode, type FindParentNodeResult } from './utils/find-parent-node.ts'
120
+ export { getMarkType } from './utils/get-mark-type.ts'
121
+ export { getNodeType } from './utils/get-node-type.ts'
122
+ export { isAtBlockStart } from './utils/is-at-block-start.ts'
123
+ export { isInCodeBlock } from './utils/is-in-code-block.ts'
124
+ export { isMarkAbsent } from './utils/is-mark-absent.ts'
125
+ export { isMarkActive } from './utils/is-mark-active.ts'
126
+ export { maybeRun } from './utils/maybe-run.ts'
127
127
  export {
128
128
  elementFromJSON,
129
129
  elementFromNode,
@@ -140,8 +140,8 @@ export {
140
140
  type DOMParserOptions,
141
141
  type DOMSerializerOptions,
142
142
  type JSONParserOptions,
143
- } from './utils/parse'
144
- export { setSelectionAround } from './utils/set-selection-around'
143
+ } from './utils/parse.ts'
144
+ export { setSelectionAround } from './utils/set-selection-around.ts'
145
145
  export {
146
146
  isAllSelection,
147
147
  isFragment,
@@ -151,6 +151,6 @@ export {
151
151
  isSelection,
152
152
  isSlice,
153
153
  isTextSelection,
154
- } from './utils/type-assertion'
155
- export * from './utils/unicode'
156
- export { withSkipCodeBlock } from './utils/with-skip-code-block'
154
+ } from './utils/type-assertion.ts'
155
+ export * from './utils/unicode.ts'
156
+ export { withSkipCodeBlock } from './utils/with-skip-code-block.ts'
package/src/test/index.ts CHANGED
@@ -1 +1 @@
1
- export { createTestEditor, type TestEditor } from './test-editor'
1
+ export { createTestEditor, type TestEditor } from './test-editor.ts'
@@ -1,7 +1,7 @@
1
1
  import type { ProseMirrorNode } from '@prosekit/pm/model'
2
2
 
3
- import type { ApplyMarkFunction, CreateNodeFunction } from '../editor/action'
4
- import { assert } from '../utils/assert'
3
+ import type { ApplyMarkFunction, CreateNodeFunction } from '../editor/action.ts'
4
+ import { assert } from '../utils/assert.ts'
5
5
 
6
6
  type Tags = Record<string, number>
7
7
  export type TaggedProseMirrorNode = ProseMirrorNode & { tags?: Tags }
@@ -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('TestEditor', () => {
6
6
  it('should create nodes and marks', () => {
@@ -1,13 +1,13 @@
1
1
  import type { ProseMirrorNode } from '@prosekit/pm/model'
2
2
  import { NodeSelection, TextSelection, type Selection } from '@prosekit/pm/state'
3
3
 
4
- import { createMarkActions, createNodeActions } from '../editor/action'
5
- import { Editor, EditorInstance, setupEditorExtension, type EditorOptions } from '../editor/editor'
6
- import type { Extension } from '../types/extension'
7
- import type { NodeJSON, SelectionJSON } from '../types/model'
8
- import { isProseMirrorNode } from '../utils/type-assertion'
4
+ import { createMarkActions, createNodeActions } from '../editor/action.ts'
5
+ import { Editor, EditorInstance, setupEditorExtension, type EditorOptions } from '../editor/editor.ts'
6
+ import type { Extension } from '../types/extension.ts'
7
+ import type { NodeJSON, SelectionJSON } from '../types/model.ts'
8
+ import { isProseMirrorNode } from '../utils/type-assertion.ts'
9
9
 
10
- import { applyMarkForTest, createNodeForTest, type TaggedProseMirrorNode } from './test-builder'
10
+ import { applyMarkForTest, createNodeForTest, type TaggedProseMirrorNode } from './test-builder.ts'
11
11
 
12
12
  function maybeResolve(doc: ProseMirrorNode, pos?: number) {
13
13
  if (pos != null) {
@@ -2,16 +2,16 @@ import '@prosekit/pm/view/style/prosemirror.css'
2
2
 
3
3
  import type { Attrs } from '@prosekit/pm/model'
4
4
 
5
- import { union } from '../editor/union'
6
- import { withPriority } from '../editor/with-priority'
7
- import { defineBaseCommands } from '../extensions/command'
8
- import { defineHistory } from '../extensions/history'
9
- import { defineBaseKeymap } from '../extensions/keymap-base'
10
- import { defineMarkSpec } from '../extensions/mark-spec'
11
- import { defineNodeSpec } from '../extensions/node-spec'
12
- import { createTestEditor, type TestEditor } from '../test'
13
- import type { Extension, ExtractMarkActions, ExtractNodeActions } from '../types/extension'
14
- import { Priority } from '../types/priority'
5
+ import { union } from '../editor/union.ts'
6
+ import { withPriority } from '../editor/with-priority.ts'
7
+ import { defineBaseCommands } from '../extensions/command.ts'
8
+ import { defineHistory } from '../extensions/history.ts'
9
+ import { defineBaseKeymap } from '../extensions/keymap-base.ts'
10
+ import { defineMarkSpec } from '../extensions/mark-spec.ts'
11
+ import { defineNodeSpec } from '../extensions/node-spec.ts'
12
+ import { createTestEditor, type TestEditor } from '../test/index.ts'
13
+ import type { Extension, ExtractMarkActions, ExtractNodeActions } from '../types/extension.ts'
14
+ import { Priority } from '../types/priority.ts'
15
15
 
16
16
  type DocExtension = Extension<{ Nodes: { doc: Attrs } }>
17
17
 
@@ -1,4 +1,4 @@
1
- import type { MarkAction } from '../editor/action'
1
+ import type { MarkAction } from '../editor/action.ts'
2
2
 
3
3
  /**
4
4
  * @internal
@@ -1,4 +1,4 @@
1
- import type { NodeAction } from '../editor/action'
1
+ import type { NodeAction } from '../editor/action.ts'
2
2
 
3
3
  /**
4
4
  * @internal
@@ -1,7 +1,7 @@
1
1
  import { test } from 'vitest'
2
2
 
3
- import { assertTypeEqual } from './assert-type-equal'
4
- import type { Extension, Union } from './extension'
3
+ import { assertTypeEqual } from './assert-type-equal.ts'
4
+ import type { Extension, Union } from './extension.ts'
5
5
 
6
6
  test('ExtractTyping', () => {
7
7
  type E1 = Extension<{
@@ -1,13 +1,13 @@
1
1
  import type { Schema } from '@prosekit/pm/model'
2
2
 
3
- import type { CommandTyping, ToCommandAction, ToCommandCreators } from './extension-command'
4
- import type { MarkTyping, ToMarkAction } from './extension-mark'
5
- import type { NodeTyping, ToNodeAction } from './extension-node'
6
- import type { PickStringLiteral } from './pick-string-literal'
7
- import type { PickSubType } from './pick-sub-type'
8
- import type { Priority } from './priority'
9
- import type { SimplifyDeeper } from './simplify-deeper'
10
- import type { SimplifyUnion } from './simplify-union'
3
+ import type { CommandTyping, ToCommandAction, ToCommandCreators } from './extension-command.ts'
4
+ import type { MarkTyping, ToMarkAction } from './extension-mark.ts'
5
+ import type { NodeTyping, ToNodeAction } from './extension-node.ts'
6
+ import type { PickStringLiteral } from './pick-string-literal.ts'
7
+ import type { PickSubType } from './pick-sub-type.ts'
8
+ import type { Priority } from './priority.ts'
9
+ import type { SimplifyDeeper } from './simplify-deeper.ts'
10
+ import type { SimplifyUnion } from './simplify-union.ts'
11
11
 
12
12
  /**
13
13
  * @internal
@@ -1,7 +1,7 @@
1
1
  import { test } from 'vitest'
2
2
 
3
- import { assertTypeEqual } from './assert-type-equal'
4
- import type { PickStringLiteral } from './pick-string-literal'
3
+ import { assertTypeEqual } from './assert-type-equal.ts'
4
+ import type { PickStringLiteral } from './pick-string-literal.ts'
5
5
 
6
6
  test('PickStringLiteral', () => {
7
7
  assertTypeEqual<PickStringLiteral<'foo'>, 'foo'>(true)
@@ -1,4 +1,4 @@
1
- import type { PickSubType } from './pick-sub-type'
1
+ import type { PickSubType } from './pick-sub-type.ts'
2
2
 
3
3
  /**
4
4
  * @internal
@@ -1,7 +1,7 @@
1
1
  import { test } from 'vitest'
2
2
 
3
- import { assertTypeEqual } from './assert-type-equal'
4
- import type { PickSubType } from './pick-sub-type'
3
+ import { assertTypeEqual } from './assert-type-equal.ts'
4
+ import type { PickSubType } from './pick-sub-type.ts'
5
5
 
6
6
  test('PickSubType', () => {
7
7
  assertTypeEqual<PickSubType<'abc', string>, 'abc'>(true)
@@ -1,12 +1,55 @@
1
1
  /**
2
2
  * ProseKit extension priority.
3
3
  *
4
+ * There are five priority levels available:
5
+ *
6
+ * - `Priority.lowest`
7
+ * - `Priority.low`
8
+ * - `Priority.default`
9
+ * - `Priority.high`
10
+ * - `Priority.highest`
11
+ *
12
+ * @example
13
+ *
14
+ * ```ts
15
+ * import { withPriority, Priority } from 'prosekit/core'
16
+ * import { myExtension } from './my-extension.js'
17
+ *
18
+ * const myExtensionWithHighPriority = withPriority(myExtension, Priority.high)
19
+ * ```
20
+ *
21
+ * @public
22
+ */
23
+ const Priority = {
24
+ lowest: 0,
25
+ low: 1,
26
+ default: 2,
27
+ high: 3,
28
+ highest: 4,
29
+ } as const
30
+
31
+ /**
32
+ * ProseKit extension priority.
33
+ *
34
+ * There are five priority levels available:
35
+ *
36
+ * - `Priority.lowest`
37
+ * - `Priority.low`
38
+ * - `Priority.default`
39
+ * - `Priority.high`
40
+ * - `Priority.highest`
41
+ *
42
+ * @example
43
+ *
44
+ * ```ts
45
+ * import { withPriority, Priority } from 'prosekit/core'
46
+ * import { myExtension } from './my-extension.js'
47
+ *
48
+ * const myExtensionWithHighPriority = withPriority(myExtension, Priority.high)
49
+ * ```
50
+ *
4
51
  * @public
5
52
  */
6
- export enum Priority {
7
- lowest = 0,
8
- low = 1,
9
- default = 2,
10
- high = 3,
11
- highest = 4,
12
- }
53
+ type Priority = typeof Priority[keyof typeof Priority]
54
+
55
+ export { Priority }
@@ -1,8 +1,8 @@
1
1
  import type { Simplify } from 'type-fest'
2
2
  import { test } from 'vitest'
3
3
 
4
- import { assertTypeEqual } from './assert-type-equal'
5
- import type { SimplifyDeeper } from './simplify-deeper'
4
+ import { assertTypeEqual } from './assert-type-equal.ts'
5
+ import type { SimplifyDeeper } from './simplify-deeper.ts'
6
6
 
7
7
  test('SimplifyDeeper', () => {
8
8
  type T1 = {
@@ -1,7 +1,7 @@
1
1
  import { test } from 'vitest'
2
2
 
3
- import { assertTypeEqual } from './assert-type-equal'
4
- import type { SimplifyUnion } from './simplify-union'
3
+ import { assertTypeEqual } from './assert-type-equal.ts'
4
+ import type { SimplifyUnion } from './simplify-union.ts'
5
5
 
6
6
  test('SimplifyUnion', () => {
7
7
  type T1 = { a: string } | { b: string }
@@ -1,6 +1,6 @@
1
1
  import { expect, test } from 'vitest'
2
2
 
3
- import { groupEntries } from './array-grouping'
3
+ import { groupEntries } from './array-grouping.ts'
4
4
 
5
5
  test('groupEntries', () => {
6
6
  expect(
@@ -1,4 +1,4 @@
1
- import { ProseKitError } from '../error'
1
+ import { ProseKitError } from '../error.ts'
2
2
 
3
3
  /**
4
4
  * @internal
@@ -1,12 +1,6 @@
1
- import { once } from '@ocavue/utils'
1
+ import { supportsRegexLookbehind } from '@ocavue/utils'
2
2
 
3
3
  /**
4
4
  * Checks if the browser supports [regex lookbehind assertion](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Lookbehind_assertion).
5
5
  */
6
- export const canUseRegexLookbehind: () => boolean = once(() => {
7
- try {
8
- return 'ab'.replace(new RegExp('(?<=a)b', 'g'), 'c') === 'ac'
9
- } catch {
10
- return false
11
- }
12
- })
6
+ export const canUseRegexLookbehind: () => boolean = supportsRegexLookbehind
@@ -1,6 +1,6 @@
1
1
  import { expect, test } from 'vitest'
2
2
 
3
- import { clsx } from './clsx'
3
+ import { clsx } from './clsx.ts'
4
4
 
5
5
  test('joins class names', () => {
6
6
  expect(clsx('foo', 'bar')).toBe('foo bar')
@@ -1,6 +1,6 @@
1
1
  import { expect, test, vi } from 'vitest'
2
2
 
3
- import { combineEventHandlers } from './combine-event-handlers'
3
+ import { combineEventHandlers } from './combine-event-handlers.ts'
4
4
 
5
5
  test('runs handlers in reverse order and stops on true', () => {
6
6
  const handler1 = vi.fn(() => false)
@@ -1,9 +1,9 @@
1
1
  import { AllSelection } from '@prosekit/pm/state'
2
2
  import { expect, test } from 'vitest'
3
3
 
4
- import { setupTest } from '../testing'
4
+ import { setupTest } from '../testing/index.ts'
5
5
 
6
- import { getEditorSelection } from './editor-content'
6
+ import { getEditorSelection } from './editor-content.ts'
7
7
 
8
8
  test('getEditorSelection', () => {
9
9
  const { n } = setupTest()
@@ -2,11 +2,11 @@ import { isElementLike } from '@ocavue/utils'
2
2
  import type { ProseMirrorNode, Schema } from '@prosekit/pm/model'
3
3
  import { Selection } from '@prosekit/pm/state'
4
4
 
5
- import type { NodeJSON, SelectionJSON } from '../types/model'
5
+ import type { NodeJSON, SelectionJSON } from '../types/model.ts'
6
6
 
7
- import { assert } from './assert'
8
- import { jsonFromElement, jsonFromHTML } from './parse'
9
- import { isProseMirrorNode, isSelection } from './type-assertion'
7
+ import { assert } from './assert.ts'
8
+ import { jsonFromElement, jsonFromHTML } from './parse.ts'
9
+ import { isProseMirrorNode, isSelection } from './type-assertion.ts'
10
10
 
11
11
  export function getEditorContentJSON(
12
12
  schema: Schema,
@@ -1,7 +1,7 @@
1
1
  import type { NodeType, ResolvedPos } from '@prosekit/pm/model'
2
2
 
3
- import { findParentNode, type FindParentNodeResult } from './find-parent-node'
4
- import { getNodeTypes } from './get-node-types'
3
+ import { findParentNode, type FindParentNodeResult } from './find-parent-node.ts'
4
+ import { getNodeTypes } from './get-node-types.ts'
5
5
 
6
6
  /**
7
7
  * Finds the closest parent node that matches the given node type.