@prosekit/core 0.9.0 → 0.11.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.
- package/dist/{editor-4lgGc3CY.d.ts → editor.d.ts} +58 -18
- package/dist/editor.d.ts.map +1 -0
- package/dist/{editor-DGNUXn-u.js → editor.js} +40 -81
- package/dist/editor.js.map +1 -0
- package/dist/prosekit-core-test.d.ts +1 -2
- package/dist/prosekit-core-test.d.ts.map +1 -1
- package/dist/prosekit-core-test.js +2 -4
- package/dist/prosekit-core-test.js.map +1 -1
- package/dist/prosekit-core.d.ts +148 -68
- package/dist/prosekit-core.d.ts.map +1 -1
- package/dist/prosekit-core.js +184 -138
- package/dist/prosekit-core.js.map +1 -1
- package/package.json +9 -9
- package/src/commands/add-mark.ts +3 -6
- package/src/commands/expand-mark.ts +4 -11
- package/src/commands/insert-default-block.spec.ts +4 -8
- package/src/commands/insert-default-block.ts +2 -5
- package/src/commands/insert-node.ts +7 -11
- package/src/commands/remove-mark.ts +3 -6
- package/src/commands/remove-node.ts +4 -4
- package/src/commands/select-block.spec.ts +6 -8
- package/src/commands/select-block.ts +2 -5
- package/src/commands/set-block-type.ts +3 -6
- package/src/commands/set-node-attrs-between.spec.ts +221 -0
- package/src/commands/set-node-attrs-between.ts +77 -0
- package/src/commands/set-node-attrs.spec.ts +129 -0
- package/src/commands/set-node-attrs.ts +26 -27
- package/src/commands/toggle-mark.ts +3 -6
- package/src/commands/toggle-node.ts +4 -7
- package/src/commands/toggle-wrap.spec.ts +2 -6
- package/src/commands/toggle-wrap.ts +3 -6
- package/src/commands/unset-block-type.spec.ts +2 -6
- package/src/commands/unset-block-type.ts +3 -9
- package/src/commands/unset-mark.spec.ts +2 -6
- package/src/commands/unset-mark.ts +1 -1
- package/src/commands/wrap.ts +2 -5
- package/src/editor/action.spec.ts +5 -9
- package/src/editor/action.ts +7 -14
- package/src/editor/editor.spec.ts +8 -15
- package/src/editor/editor.ts +18 -52
- package/src/editor/union.spec.ts +8 -12
- package/src/editor/union.ts +4 -7
- package/src/editor/with-priority.ts +3 -3
- package/src/error.ts +8 -1
- package/src/extensions/clipboard-serializer.ts +22 -26
- package/src/extensions/command.ts +22 -54
- package/src/extensions/default-state.spec.ts +4 -8
- package/src/extensions/default-state.ts +6 -12
- package/src/extensions/events/doc-change.ts +2 -2
- package/src/extensions/events/dom-event.spec.ts +4 -9
- package/src/extensions/events/dom-event.ts +9 -21
- package/src/extensions/events/editor-event.ts +8 -20
- package/src/extensions/events/focus.spec.ts +7 -12
- package/src/extensions/events/focus.ts +2 -2
- package/src/extensions/events/plugin-view.ts +5 -12
- package/src/extensions/history.ts +7 -14
- package/src/extensions/keymap-base.spec.ts +6 -15
- package/src/extensions/keymap-base.ts +6 -9
- package/src/extensions/keymap.spec.ts +10 -24
- package/src/extensions/keymap.ts +5 -15
- package/src/extensions/mark-spec.spec.ts +6 -21
- package/src/extensions/mark-spec.ts +10 -21
- package/src/extensions/mark-view-effect.ts +6 -12
- package/src/extensions/mark-view.ts +5 -11
- package/src/extensions/node-spec.spec.ts +10 -26
- package/src/extensions/node-spec.ts +10 -21
- package/src/extensions/node-view-effect.ts +6 -12
- package/src/extensions/node-view.ts +5 -11
- package/src/extensions/plugin.spec.ts +9 -22
- package/src/extensions/plugin.ts +6 -15
- package/src/facets/base-extension.ts +7 -10
- package/src/facets/command.ts +3 -9
- package/src/facets/facet-extension.spec.ts +10 -21
- package/src/facets/facet-extension.ts +12 -8
- package/src/facets/facet-node.spec.ts +4 -11
- package/src/facets/facet-node.ts +27 -22
- package/src/facets/facet.spec.ts +2 -5
- package/src/facets/facet.ts +14 -7
- package/src/facets/root.ts +2 -2
- package/src/facets/schema-spec.ts +3 -10
- package/src/facets/schema.ts +4 -13
- package/src/facets/state.spec.ts +8 -15
- package/src/facets/state.ts +5 -19
- package/src/facets/union-extension.ts +10 -13
- package/src/index.ts +74 -200
- package/src/test/index.ts +1 -4
- package/src/test/test-builder.ts +2 -5
- package/src/test/test-editor.spec.ts +2 -6
- package/src/test/test-editor.ts +7 -26
- package/src/testing/index.ts +26 -22
- package/src/types/extension-mark.ts +1 -1
- package/src/types/extension-node.ts +1 -1
- package/src/types/extension.spec.ts +2 -5
- package/src/types/extension.ts +8 -18
- package/src/types/pick-string-literal.spec.ts +2 -2
- package/src/types/pick-string-literal.ts +1 -1
- package/src/types/pick-sub-type.spec.ts +2 -2
- package/src/types/priority.ts +50 -7
- package/src/types/simplify-deeper.spec.ts +2 -2
- package/src/types/simplify-union.spec.ts +2 -2
- package/src/types/simplify-union.ts +1 -4
- package/src/utils/array-grouping.spec.ts +2 -5
- package/src/utils/assert.ts +1 -1
- package/src/utils/attrs-match.ts +1 -5
- package/src/utils/can-use-regex-lookbehind.ts +2 -8
- package/src/utils/clsx.spec.ts +2 -5
- package/src/utils/combine-event-handlers.spec.ts +2 -6
- package/src/utils/default-block-at.ts +1 -4
- package/src/utils/editor-content.spec.ts +3 -6
- package/src/utils/editor-content.ts +5 -17
- package/src/utils/find-node.ts +65 -0
- package/src/utils/find-parent-node-of-type.ts +6 -12
- package/src/utils/find-parent-node.spec.ts +3 -7
- package/src/utils/find-parent-node.ts +1 -4
- package/src/utils/get-custom-selection.ts +1 -5
- package/src/utils/get-dom-api.ts +1 -1
- package/src/utils/get-mark-type.ts +2 -5
- package/src/utils/get-node-type.ts +2 -5
- package/src/utils/get-node-types.ts +2 -5
- package/src/utils/includes-mark.ts +2 -6
- package/src/utils/is-at-block-start.ts +1 -4
- package/src/utils/is-mark-absent.spec.ts +3 -6
- package/src/utils/is-mark-absent.ts +2 -6
- package/src/utils/is-mark-active.ts +4 -7
- package/src/utils/is-node-active.spec.ts +109 -0
- package/src/utils/is-node-active.ts +19 -10
- package/src/utils/is-subset.spec.ts +2 -5
- package/src/utils/maybe-run.spec.ts +2 -6
- package/src/utils/merge-objects.spec.ts +2 -5
- package/src/utils/merge-objects.ts +3 -2
- package/src/utils/merge-specs.ts +2 -5
- package/src/utils/object-equal.spec.ts +2 -5
- package/src/utils/output-spec.test.ts +2 -6
- package/src/utils/output-spec.ts +2 -10
- package/src/utils/parse.spec.ts +6 -15
- package/src/utils/parse.ts +4 -16
- package/src/utils/remove-undefined-values.spec.ts +2 -5
- package/src/utils/set-selection-around.ts +1 -4
- package/src/utils/type-assertion.ts +2 -21
- package/src/utils/unicode.spec.ts +2 -5
- package/src/utils/with-skip-code-block.ts +1 -1
- package/dist/editor-4lgGc3CY.d.ts.map +0 -1
- package/dist/editor-DGNUXn-u.js.map +0 -1
package/src/index.ts
CHANGED
|
@@ -1,98 +1,30 @@
|
|
|
1
|
-
export {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
} from './commands/
|
|
5
|
-
export {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
} from './commands/
|
|
9
|
-
export {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
} from './commands/
|
|
13
|
-
export {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
} from './commands/
|
|
17
|
-
export {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
} from './
|
|
21
|
-
export {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
} from './
|
|
25
|
-
export {
|
|
26
|
-
export {
|
|
27
|
-
export {
|
|
28
|
-
setBlockType,
|
|
29
|
-
type SetBlockTypeOptions,
|
|
30
|
-
} from './commands/set-block-type'
|
|
31
|
-
export {
|
|
32
|
-
setNodeAttrs,
|
|
33
|
-
type SetNodeAttrsOptions,
|
|
34
|
-
} from './commands/set-node-attrs'
|
|
35
|
-
export {
|
|
36
|
-
toggleMark,
|
|
37
|
-
type ToggleMarkOptions,
|
|
38
|
-
} from './commands/toggle-mark'
|
|
39
|
-
export {
|
|
40
|
-
toggleNode,
|
|
41
|
-
type ToggleNodeOptions,
|
|
42
|
-
} from './commands/toggle-node'
|
|
43
|
-
export {
|
|
44
|
-
toggleWrap,
|
|
45
|
-
type ToggleWrapOptions,
|
|
46
|
-
} from './commands/toggle-wrap'
|
|
47
|
-
export {
|
|
48
|
-
unsetBlockType,
|
|
49
|
-
type UnsetBlockTypeOptions,
|
|
50
|
-
} from './commands/unset-block-type'
|
|
51
|
-
export {
|
|
52
|
-
unsetMark,
|
|
53
|
-
type UnsetMarkOptions,
|
|
54
|
-
} from './commands/unset-mark'
|
|
55
|
-
export {
|
|
56
|
-
wrap,
|
|
57
|
-
type WrapOptions,
|
|
58
|
-
} from './commands/wrap'
|
|
59
|
-
export type {
|
|
60
|
-
MarkAction,
|
|
61
|
-
NodeAction,
|
|
62
|
-
NodeChild,
|
|
63
|
-
} from './editor/action'
|
|
64
|
-
export {
|
|
65
|
-
createEditor,
|
|
66
|
-
Editor,
|
|
67
|
-
type EditorOptions,
|
|
68
|
-
} from './editor/editor'
|
|
69
|
-
export { union } from './editor/union'
|
|
70
|
-
export { withPriority } from './editor/with-priority'
|
|
71
|
-
export {
|
|
72
|
-
EditorNotFoundError,
|
|
73
|
-
ProseKitError,
|
|
74
|
-
} from './error'
|
|
75
|
-
export {
|
|
76
|
-
defineClipboardSerializer,
|
|
77
|
-
type ClipboardSerializerOptions,
|
|
78
|
-
} from './extensions/clipboard-serializer'
|
|
79
|
-
export {
|
|
80
|
-
defineBaseCommands,
|
|
81
|
-
defineCommands,
|
|
82
|
-
type BaseCommandsExtension,
|
|
83
|
-
} from './extensions/command'
|
|
84
|
-
export {
|
|
85
|
-
defineDefaultState,
|
|
86
|
-
type DefaultStateOptions,
|
|
87
|
-
} from './extensions/default-state'
|
|
88
|
-
export {
|
|
89
|
-
defineDocChangeHandler,
|
|
90
|
-
type DocChangeHandler,
|
|
91
|
-
} from './extensions/events/doc-change'
|
|
92
|
-
export {
|
|
93
|
-
defineDOMEventHandler,
|
|
94
|
-
type DOMEventHandler,
|
|
95
|
-
} 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'
|
|
96
28
|
export {
|
|
97
29
|
defineClickHandler,
|
|
98
30
|
defineClickOnHandler,
|
|
@@ -120,11 +52,8 @@ export {
|
|
|
120
52
|
type TextInputHandler,
|
|
121
53
|
type TripleClickHandler,
|
|
122
54
|
type TripleClickOnHandler,
|
|
123
|
-
} from './extensions/events/editor-event'
|
|
124
|
-
export {
|
|
125
|
-
defineFocusChangeHandler,
|
|
126
|
-
type FocusChangeHandler,
|
|
127
|
-
} from './extensions/events/focus'
|
|
55
|
+
} from './extensions/events/editor-event.ts'
|
|
56
|
+
export { defineFocusChangeHandler, type FocusChangeHandler } from './extensions/events/focus.ts'
|
|
128
57
|
export {
|
|
129
58
|
defineMountHandler,
|
|
130
59
|
defineUnmountHandler,
|
|
@@ -132,70 +61,34 @@ export {
|
|
|
132
61
|
type MountHandler,
|
|
133
62
|
type UnmountHandler,
|
|
134
63
|
type UpdateHandler,
|
|
135
|
-
} from './extensions/events/plugin-view'
|
|
136
|
-
export {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
} from './extensions/history'
|
|
141
|
-
export {
|
|
142
|
-
defineKeymap,
|
|
143
|
-
keymapFacet,
|
|
144
|
-
type Keymap,
|
|
145
|
-
type KeymapPayload,
|
|
146
|
-
} from './extensions/keymap'
|
|
147
|
-
export {
|
|
148
|
-
defineBaseKeymap,
|
|
149
|
-
type BaseKeymapExtension,
|
|
150
|
-
type BaseKeymapOptions,
|
|
151
|
-
} from './extensions/keymap-base'
|
|
152
|
-
export {
|
|
153
|
-
defineMarkAttr,
|
|
154
|
-
defineMarkSpec,
|
|
155
|
-
type MarkAttrOptions,
|
|
156
|
-
type MarkSpecOptions,
|
|
157
|
-
} from './extensions/mark-spec'
|
|
158
|
-
export {
|
|
159
|
-
defineMarkView,
|
|
160
|
-
type MarkViewOptions,
|
|
161
|
-
} 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'
|
|
162
69
|
export {
|
|
163
70
|
defineMarkViewComponent,
|
|
164
71
|
defineMarkViewFactory,
|
|
165
72
|
type MarkViewComponentOptions,
|
|
166
73
|
type MarkViewFactoryOptions,
|
|
167
|
-
} from './extensions/mark-view-effect'
|
|
168
|
-
export {
|
|
169
|
-
|
|
170
|
-
defineNodeSpec,
|
|
171
|
-
type NodeAttrOptions,
|
|
172
|
-
type NodeSpecOptions,
|
|
173
|
-
} from './extensions/node-spec'
|
|
174
|
-
export {
|
|
175
|
-
defineNodeView,
|
|
176
|
-
type NodeViewOptions,
|
|
177
|
-
} 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'
|
|
178
77
|
export {
|
|
179
78
|
defineNodeViewComponent,
|
|
180
79
|
defineNodeViewFactory,
|
|
181
80
|
type NodeViewComponentOptions,
|
|
182
81
|
type NodeViewFactoryOptions,
|
|
183
|
-
} from './extensions/node-view-effect'
|
|
184
|
-
export {
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
} from './
|
|
189
|
-
export {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
} from './
|
|
193
|
-
export { defineFacetPayload } from './facets/facet-extension'
|
|
194
|
-
export type { AnyFunction } from './types/any-function'
|
|
195
|
-
export type {
|
|
196
|
-
AnyAttrs,
|
|
197
|
-
AttrSpec,
|
|
198
|
-
} 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'
|
|
199
92
|
export type {
|
|
200
93
|
Extension,
|
|
201
94
|
ExtensionTyping,
|
|
@@ -209,47 +102,28 @@ export type {
|
|
|
209
102
|
ExtractTyping,
|
|
210
103
|
PlainExtension,
|
|
211
104
|
Union,
|
|
212
|
-
} from './types/extension'
|
|
213
|
-
export type {
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
} from './types/
|
|
217
|
-
export type {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
} from './
|
|
221
|
-
export
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
} from './
|
|
225
|
-
export type
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
} from './
|
|
231
|
-
export
|
|
232
|
-
export {
|
|
233
|
-
export
|
|
234
|
-
export type { SimplifyUnion } from './types/simplify-union'
|
|
235
|
-
export { assert } from './utils/assert'
|
|
236
|
-
export { canUseRegexLookbehind } from './utils/can-use-regex-lookbehind'
|
|
237
|
-
export { clsx } from './utils/clsx'
|
|
238
|
-
export { containsInlineNode } from './utils/contains-inline-node'
|
|
239
|
-
export { defaultBlockAt } from './utils/default-block-at'
|
|
240
|
-
export { isApple } from './utils/env'
|
|
241
|
-
export {
|
|
242
|
-
findParentNode,
|
|
243
|
-
type FindParentNodeResult,
|
|
244
|
-
} from './utils/find-parent-node'
|
|
245
|
-
export { findParentNodeOfType } from './utils/find-parent-node-of-type'
|
|
246
|
-
export { getMarkType } from './utils/get-mark-type'
|
|
247
|
-
export { getNodeType } from './utils/get-node-type'
|
|
248
|
-
export { isAtBlockStart } from './utils/is-at-block-start'
|
|
249
|
-
export { isInCodeBlock } from './utils/is-in-code-block'
|
|
250
|
-
export { isMarkAbsent } from './utils/is-mark-absent'
|
|
251
|
-
export { isMarkActive } from './utils/is-mark-active'
|
|
252
|
-
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'
|
|
253
127
|
export {
|
|
254
128
|
elementFromJSON,
|
|
255
129
|
elementFromNode,
|
|
@@ -266,8 +140,8 @@ export {
|
|
|
266
140
|
type DOMParserOptions,
|
|
267
141
|
type DOMSerializerOptions,
|
|
268
142
|
type JSONParserOptions,
|
|
269
|
-
} from './utils/parse'
|
|
270
|
-
export { setSelectionAround } from './utils/set-selection-around'
|
|
143
|
+
} from './utils/parse.ts'
|
|
144
|
+
export { setSelectionAround } from './utils/set-selection-around.ts'
|
|
271
145
|
export {
|
|
272
146
|
isAllSelection,
|
|
273
147
|
isFragment,
|
|
@@ -277,6 +151,6 @@ export {
|
|
|
277
151
|
isSelection,
|
|
278
152
|
isSlice,
|
|
279
153
|
isTextSelection,
|
|
280
|
-
} from './utils/type-assertion'
|
|
281
|
-
export * from './utils/unicode'
|
|
282
|
-
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
package/src/test/test-builder.ts
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import type { ProseMirrorNode } from '@prosekit/pm/model'
|
|
2
2
|
|
|
3
|
-
import type {
|
|
4
|
-
|
|
5
|
-
CreateNodeFunction,
|
|
6
|
-
} from '../editor/action'
|
|
7
|
-
import { assert } from '../utils/assert'
|
|
3
|
+
import type { ApplyMarkFunction, CreateNodeFunction } from '../editor/action.ts'
|
|
4
|
+
import { assert } from '../utils/assert.ts'
|
|
8
5
|
|
|
9
6
|
type Tags = Record<string, number>
|
|
10
7
|
export type TaggedProseMirrorNode = ProseMirrorNode & { tags?: Tags }
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
describe,
|
|
3
|
-
expect,
|
|
4
|
-
it,
|
|
5
|
-
} from 'vitest'
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
6
2
|
|
|
7
|
-
import { setupTest } from '../testing'
|
|
3
|
+
import { setupTest } from '../testing/index.ts'
|
|
8
4
|
|
|
9
5
|
describe('TestEditor', () => {
|
|
10
6
|
it('should create nodes and marks', () => {
|
package/src/test/test-editor.ts
CHANGED
|
@@ -1,32 +1,13 @@
|
|
|
1
1
|
import type { ProseMirrorNode } from '@prosekit/pm/model'
|
|
2
|
-
import {
|
|
3
|
-
NodeSelection,
|
|
4
|
-
TextSelection,
|
|
5
|
-
type Selection,
|
|
6
|
-
} from '@prosekit/pm/state'
|
|
2
|
+
import { NodeSelection, TextSelection, type Selection } from '@prosekit/pm/state'
|
|
7
3
|
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
} from '../
|
|
12
|
-
import {
|
|
13
|
-
Editor,
|
|
14
|
-
EditorInstance,
|
|
15
|
-
setupEditorExtension,
|
|
16
|
-
type EditorOptions,
|
|
17
|
-
} from '../editor/editor'
|
|
18
|
-
import type { Extension } from '../types/extension'
|
|
19
|
-
import type {
|
|
20
|
-
NodeJSON,
|
|
21
|
-
SelectionJSON,
|
|
22
|
-
} from '../types/model'
|
|
23
|
-
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'
|
|
24
9
|
|
|
25
|
-
import {
|
|
26
|
-
applyMarkForTest,
|
|
27
|
-
createNodeForTest,
|
|
28
|
-
type TaggedProseMirrorNode,
|
|
29
|
-
} from './test-builder'
|
|
10
|
+
import { applyMarkForTest, createNodeForTest, type TaggedProseMirrorNode } from './test-builder.ts'
|
|
30
11
|
|
|
31
12
|
function maybeResolve(doc: ProseMirrorNode, pos?: number) {
|
|
32
13
|
if (pos != null) {
|
package/src/testing/index.ts
CHANGED
|
@@ -2,23 +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 {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
} from '../test'
|
|
16
|
-
import type {
|
|
17
|
-
Extension,
|
|
18
|
-
ExtractMarkActions,
|
|
19
|
-
ExtractNodeActions,
|
|
20
|
-
} from '../types/extension'
|
|
21
|
-
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'
|
|
22
15
|
|
|
23
16
|
type DocExtension = Extension<{ Nodes: { doc: Attrs } }>
|
|
24
17
|
|
|
@@ -182,7 +175,7 @@ function defineHeading(): HeadingExtension {
|
|
|
182
175
|
|
|
183
176
|
type CodeBlockExtension = Extension<{
|
|
184
177
|
Nodes: {
|
|
185
|
-
codeBlock: { language: string }
|
|
178
|
+
codeBlock: { language: string; lineNumbers?: boolean }
|
|
186
179
|
}
|
|
187
180
|
}>
|
|
188
181
|
|
|
@@ -197,16 +190,23 @@ function defineCodeBlock(): CodeBlockExtension {
|
|
|
197
190
|
code: true,
|
|
198
191
|
defining: true,
|
|
199
192
|
marks: '',
|
|
200
|
-
attrs: {
|
|
193
|
+
attrs: {
|
|
194
|
+
language: { default: '', validate: 'string' },
|
|
195
|
+
lineNumbers: { default: false, validate: 'boolean' },
|
|
196
|
+
},
|
|
201
197
|
toDOM() {
|
|
202
198
|
return ['pre', ['code', 0]]
|
|
203
199
|
},
|
|
204
200
|
})
|
|
205
201
|
}
|
|
206
202
|
|
|
203
|
+
interface BlockquoteAttrs {
|
|
204
|
+
variant: string
|
|
205
|
+
}
|
|
206
|
+
|
|
207
207
|
type BlockquoteExtension = Extension<{
|
|
208
208
|
Nodes: {
|
|
209
|
-
blockquote:
|
|
209
|
+
blockquote: BlockquoteAttrs
|
|
210
210
|
}
|
|
211
211
|
}>
|
|
212
212
|
|
|
@@ -219,9 +219,13 @@ function defineBlockquote(): BlockquoteExtension {
|
|
|
219
219
|
content: 'block+',
|
|
220
220
|
group: 'block',
|
|
221
221
|
defining: true,
|
|
222
|
+
attrs: {
|
|
223
|
+
variant: { default: '', validate: 'string' },
|
|
224
|
+
},
|
|
222
225
|
parseDOM: [{ tag: 'blockquote' }],
|
|
223
|
-
toDOM() {
|
|
224
|
-
|
|
226
|
+
toDOM(node) {
|
|
227
|
+
const { variant } = node.attrs as BlockquoteAttrs
|
|
228
|
+
return ['blockquote', { 'data-variant': variant }, 0]
|
|
225
229
|
},
|
|
226
230
|
})
|
|
227
231
|
}
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { test } from 'vitest'
|
|
2
2
|
|
|
3
|
-
import { assertTypeEqual } from './assert-type-equal'
|
|
4
|
-
import type {
|
|
5
|
-
Extension,
|
|
6
|
-
Union,
|
|
7
|
-
} from './extension'
|
|
3
|
+
import { assertTypeEqual } from './assert-type-equal.ts'
|
|
4
|
+
import type { Extension, Union } from './extension.ts'
|
|
8
5
|
|
|
9
6
|
test('ExtractTyping', () => {
|
|
10
7
|
type E1 = Extension<{
|
package/src/types/extension.ts
CHANGED
|
@@ -1,23 +1,13 @@
|
|
|
1
1
|
import type { Schema } from '@prosekit/pm/model'
|
|
2
2
|
|
|
3
|
-
import type {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} from './
|
|
8
|
-
import type {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
} from './extension-mark'
|
|
12
|
-
import type {
|
|
13
|
-
NodeTyping,
|
|
14
|
-
ToNodeAction,
|
|
15
|
-
} from './extension-node'
|
|
16
|
-
import type { PickStringLiteral } from './pick-string-literal'
|
|
17
|
-
import type { PickSubType } from './pick-sub-type'
|
|
18
|
-
import type { Priority } from './priority'
|
|
19
|
-
import type { SimplifyDeeper } from './simplify-deeper'
|
|
20
|
-
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'
|
|
21
11
|
|
|
22
12
|
/**
|
|
23
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,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)
|
package/src/types/priority.ts
CHANGED
|
@@ -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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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 }
|