@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.
- package/dist/{editor-BULC1zqX.d.ts → editor.d.ts} +48 -8
- package/dist/editor.d.ts.map +1 -0
- package/dist/{editor-g-Rqn-ZE.js → editor.js} +19 -60
- package/dist/editor.js.map +1 -0
- package/dist/prosekit-core-test.d.ts +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 +69 -68
- package/dist/prosekit-core.d.ts.map +1 -1
- package/dist/prosekit-core.js +100 -135
- package/dist/prosekit-core.js.map +1 -1
- package/package.json +6 -5
- package/src/commands/add-mark.ts +2 -2
- package/src/commands/expand-mark.ts +1 -1
- package/src/commands/insert-default-block.spec.ts +3 -3
- package/src/commands/insert-default-block.ts +1 -1
- package/src/commands/insert-node.ts +3 -3
- package/src/commands/remove-mark.ts +2 -2
- package/src/commands/remove-node.ts +2 -2
- package/src/commands/select-block.spec.ts +2 -2
- package/src/commands/select-block.ts +1 -1
- package/src/commands/set-block-type.ts +2 -2
- package/src/commands/set-node-attrs-between.spec.ts +2 -2
- package/src/commands/set-node-attrs-between.ts +1 -1
- package/src/commands/set-node-attrs.spec.ts +2 -2
- package/src/commands/set-node-attrs.ts +2 -2
- package/src/commands/toggle-mark.ts +2 -2
- package/src/commands/toggle-node.ts +2 -2
- package/src/commands/toggle-wrap.spec.ts +1 -1
- package/src/commands/toggle-wrap.ts +2 -2
- package/src/commands/unset-block-type.spec.ts +1 -1
- package/src/commands/unset-block-type.ts +1 -1
- package/src/commands/unset-mark.spec.ts +1 -1
- package/src/commands/unset-mark.ts +1 -1
- package/src/commands/wrap.ts +1 -1
- package/src/editor/action.spec.ts +3 -3
- package/src/editor/action.ts +6 -6
- package/src/editor/editor.spec.ts +5 -5
- package/src/editor/editor.ts +13 -13
- package/src/editor/union.spec.ts +7 -7
- package/src/editor/union.ts +4 -4
- package/src/editor/with-priority.ts +3 -3
- package/src/error.ts +8 -1
- package/src/extensions/clipboard-serializer.ts +17 -9
- package/src/extensions/command.ts +19 -19
- package/src/extensions/default-state.spec.ts +3 -3
- package/src/extensions/default-state.ts +5 -5
- package/src/extensions/events/doc-change.ts +2 -2
- package/src/extensions/events/dom-event.spec.ts +3 -3
- package/src/extensions/events/dom-event.ts +7 -7
- package/src/extensions/events/editor-event.ts +6 -6
- package/src/extensions/events/focus.spec.ts +4 -4
- package/src/extensions/events/focus.ts +2 -2
- package/src/extensions/events/plugin-view.ts +4 -4
- package/src/extensions/history.ts +6 -6
- package/src/extensions/keymap-base.spec.ts +5 -5
- package/src/extensions/keymap-base.ts +6 -6
- package/src/extensions/keymap.spec.ts +5 -5
- package/src/extensions/keymap.ts +4 -4
- package/src/extensions/mark-spec.spec.ts +3 -3
- package/src/extensions/mark-spec.ts +8 -8
- package/src/extensions/mark-view-effect.ts +4 -4
- package/src/extensions/mark-view.ts +4 -4
- package/src/extensions/node-spec.spec.ts +5 -5
- package/src/extensions/node-spec.ts +8 -8
- package/src/extensions/node-view-effect.ts +4 -4
- package/src/extensions/node-view.ts +4 -4
- package/src/extensions/plugin.spec.ts +5 -5
- package/src/extensions/plugin.ts +5 -5
- package/src/facets/base-extension.ts +7 -7
- package/src/facets/command.ts +3 -3
- package/src/facets/facet-extension.spec.ts +6 -6
- package/src/facets/facet-extension.ts +12 -8
- package/src/facets/facet-node.spec.ts +3 -3
- package/src/facets/facet-node.ts +24 -14
- package/src/facets/facet.spec.ts +1 -1
- package/src/facets/facet.ts +14 -7
- package/src/facets/root.ts +2 -2
- package/src/facets/schema-spec.ts +2 -2
- package/src/facets/schema.ts +3 -3
- package/src/facets/state.spec.ts +6 -6
- package/src/facets/state.ts +3 -3
- package/src/facets/union-extension.ts +9 -6
- package/src/index.ts +74 -74
- package/src/test/index.ts +1 -1
- package/src/test/test-builder.ts +2 -2
- package/src/test/test-editor.spec.ts +1 -1
- package/src/test/test-editor.ts +6 -6
- package/src/testing/index.ts +10 -10
- package/src/types/extension-mark.ts +1 -1
- package/src/types/extension-node.ts +1 -1
- package/src/types/extension.spec.ts +2 -2
- package/src/types/extension.ts +8 -8
- 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/utils/array-grouping.spec.ts +1 -1
- package/src/utils/assert.ts +1 -1
- package/src/utils/can-use-regex-lookbehind.ts +2 -8
- package/src/utils/clsx.spec.ts +1 -1
- package/src/utils/combine-event-handlers.spec.ts +1 -1
- package/src/utils/editor-content.spec.ts +2 -2
- package/src/utils/editor-content.ts +4 -4
- package/src/utils/find-parent-node-of-type.ts +2 -2
- package/src/utils/find-parent-node.spec.ts +2 -2
- package/src/utils/get-dom-api.ts +1 -1
- package/src/utils/get-mark-type.ts +1 -1
- package/src/utils/get-node-type.ts +1 -1
- package/src/utils/get-node-types.ts +1 -1
- package/src/utils/includes-mark.ts +1 -1
- package/src/utils/is-mark-absent.spec.ts +2 -2
- package/src/utils/is-mark-absent.ts +1 -1
- package/src/utils/is-mark-active.ts +3 -3
- package/src/utils/is-node-active.spec.ts +2 -2
- package/src/utils/is-node-active.ts +3 -3
- package/src/utils/is-subset.spec.ts +1 -1
- package/src/utils/maybe-run.spec.ts +1 -1
- package/src/utils/merge-objects.spec.ts +1 -1
- package/src/utils/merge-objects.ts +1 -1
- package/src/utils/merge-specs.ts +1 -1
- package/src/utils/object-equal.spec.ts +1 -1
- package/src/utils/output-spec.test.ts +1 -1
- package/src/utils/parse.spec.ts +3 -3
- package/src/utils/parse.ts +3 -3
- package/src/utils/remove-undefined-values.spec.ts +1 -1
- package/src/utils/unicode.spec.ts +1 -1
- package/src/utils/with-skip-code-block.ts +1 -1
- package/dist/editor-BULC1zqX.d.ts.map +0 -1
- package/dist/editor-g-Rqn-ZE.js.map +0 -1
package/src/facets/root.ts
CHANGED
|
@@ -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 => {
|
package/src/facets/schema.ts
CHANGED
|
@@ -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) => {
|
package/src/facets/state.spec.ts
CHANGED
|
@@ -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', () => {
|
package/src/facets/state.ts
CHANGED
|
@@ -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(
|
|
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 {
|
|
11
|
-
export {
|
|
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 {
|
|
67
|
-
export {
|
|
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 {
|
|
77
|
-
export {
|
|
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 {
|
|
85
|
-
export {
|
|
86
|
-
export { defineFacetPayload } from './facets/facet-extension'
|
|
87
|
-
export type
|
|
88
|
-
export type {
|
|
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 {
|
|
104
|
-
export type {
|
|
105
|
-
export
|
|
106
|
-
export type {
|
|
107
|
-
export type {
|
|
108
|
-
export {
|
|
109
|
-
export
|
|
110
|
-
export
|
|
111
|
-
export {
|
|
112
|
-
export {
|
|
113
|
-
export {
|
|
114
|
-
export {
|
|
115
|
-
export {
|
|
116
|
-
export {
|
|
117
|
-
export {
|
|
118
|
-
export {
|
|
119
|
-
export {
|
|
120
|
-
export {
|
|
121
|
-
export {
|
|
122
|
-
export {
|
|
123
|
-
export {
|
|
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'
|
package/src/test/test-builder.ts
CHANGED
|
@@ -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 }
|
package/src/test/test-editor.ts
CHANGED
|
@@ -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) {
|
package/src/testing/index.ts
CHANGED
|
@@ -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,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<{
|
package/src/types/extension.ts
CHANGED
|
@@ -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,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 }
|
package/src/utils/assert.ts
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
import {
|
|
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 =
|
|
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
|
package/src/utils/clsx.spec.ts
CHANGED
|
@@ -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.
|