@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
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
describe,
|
|
3
|
-
expect,
|
|
4
|
-
it,
|
|
5
|
-
} from 'vitest'
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
6
2
|
|
|
7
|
-
import { createEditor } from '../editor/editor'
|
|
8
|
-
import { defineTestExtension } from '../testing'
|
|
3
|
+
import { createEditor } from '../editor/editor.ts'
|
|
4
|
+
import { defineTestExtension } from '../testing/index.ts'
|
|
9
5
|
|
|
10
|
-
import type { DefaultStateOptions } from './default-state'
|
|
6
|
+
import type { DefaultStateOptions } from './default-state.ts'
|
|
11
7
|
|
|
12
8
|
describe('defineDefaultState', () => {
|
|
13
9
|
const docJSON = {
|
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Selection,
|
|
3
|
-
type EditorStateConfig,
|
|
4
|
-
} from '@prosekit/pm/state'
|
|
1
|
+
import { Selection, type EditorStateConfig } from '@prosekit/pm/state'
|
|
5
2
|
|
|
6
|
-
import { defineFacetPayload } from '../facets/facet-extension'
|
|
7
|
-
import { stateFacet } from '../facets/state'
|
|
8
|
-
import type { PlainExtension } from '../types/extension'
|
|
9
|
-
import type {
|
|
10
|
-
|
|
11
|
-
SelectionJSON,
|
|
12
|
-
} from '../types/model'
|
|
13
|
-
import { getEditorContentJSON } from '../utils/editor-content'
|
|
3
|
+
import { defineFacetPayload } from '../facets/facet-extension.ts'
|
|
4
|
+
import { stateFacet } from '../facets/state.ts'
|
|
5
|
+
import type { PlainExtension } from '../types/extension.ts'
|
|
6
|
+
import type { NodeJSON, SelectionJSON } from '../types/model.ts'
|
|
7
|
+
import { getEditorContentJSON } from '../utils/editor-content.ts'
|
|
14
8
|
|
|
15
9
|
/**
|
|
16
10
|
* @public
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { EditorState } from '@prosekit/pm/state'
|
|
2
2
|
import type { EditorView } from '@prosekit/pm/view'
|
|
3
3
|
|
|
4
|
-
import type { PlainExtension } from '../../types/extension'
|
|
4
|
+
import type { PlainExtension } from '../../types/extension.ts'
|
|
5
5
|
|
|
6
|
-
import { defineUpdateHandler } from './plugin-view'
|
|
6
|
+
import { defineUpdateHandler } from './plugin-view.ts'
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* A function that is called when the editor document is changed.
|
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
describe,
|
|
3
|
-
expect,
|
|
4
|
-
it,
|
|
5
|
-
vi,
|
|
6
|
-
} from 'vitest'
|
|
1
|
+
import { describe, expect, it, vi } from 'vitest'
|
|
7
2
|
|
|
8
|
-
import { createEditor } from '../../editor/editor'
|
|
9
|
-
import { defineTestExtension } from '../../testing'
|
|
3
|
+
import { createEditor } from '../../editor/editor.ts'
|
|
4
|
+
import { defineTestExtension } from '../../testing/index.ts'
|
|
10
5
|
|
|
11
|
-
import { defineDOMEventHandler } from './dom-event'
|
|
6
|
+
import { defineDOMEventHandler } from './dom-event.ts'
|
|
12
7
|
|
|
13
8
|
describe('defineDOMEventHandler', () => {
|
|
14
9
|
it('should register and unregister event handlers dynamically', () => {
|
|
@@ -1,25 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
ProseMirrorPlugin,
|
|
4
|
-
} from '@prosekit/pm/state'
|
|
5
|
-
import type {
|
|
6
|
-
DOMEventMap,
|
|
7
|
-
EditorView,
|
|
8
|
-
} from '@prosekit/pm/view'
|
|
1
|
+
import { PluginKey, ProseMirrorPlugin } from '@prosekit/pm/state'
|
|
2
|
+
import type { DOMEventMap, EditorView } from '@prosekit/pm/view'
|
|
9
3
|
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
} from '../../
|
|
14
|
-
import {
|
|
15
|
-
import
|
|
16
|
-
import type
|
|
17
|
-
import { groupEntries } from '../../utils/array-grouping'
|
|
18
|
-
import { combineEventHandlers } from '../../utils/combine-event-handlers'
|
|
19
|
-
import {
|
|
20
|
-
pluginFacet,
|
|
21
|
-
type PluginPayload,
|
|
22
|
-
} from '../plugin'
|
|
4
|
+
import { defineFacetPayload } from '../../facets/facet-extension.ts'
|
|
5
|
+
import { defineFacet, type Facet } from '../../facets/facet.ts'
|
|
6
|
+
import type { PlainExtension } from '../../types/extension.ts'
|
|
7
|
+
import type { Setter } from '../../types/setter.ts'
|
|
8
|
+
import { groupEntries } from '../../utils/array-grouping.ts'
|
|
9
|
+
import { combineEventHandlers } from '../../utils/combine-event-handlers.ts'
|
|
10
|
+
import { pluginFacet, type PluginPayload } from '../plugin.ts'
|
|
23
11
|
|
|
24
12
|
/**
|
|
25
13
|
* A function to handle the events fired on the editable DOM element. Returns
|
|
@@ -1,26 +1,14 @@
|
|
|
1
1
|
import type { ObjectEntries } from '@ocavue/utils'
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
Slice,
|
|
5
|
-
} from '@prosekit/pm/model'
|
|
6
|
-
import {
|
|
7
|
-
PluginKey,
|
|
8
|
-
ProseMirrorPlugin,
|
|
9
|
-
} from '@prosekit/pm/state'
|
|
2
|
+
import type { Node, Slice } from '@prosekit/pm/model'
|
|
3
|
+
import { PluginKey, ProseMirrorPlugin } from '@prosekit/pm/state'
|
|
10
4
|
import type { EditorView } from '@prosekit/pm/view'
|
|
11
5
|
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
} from '../../
|
|
16
|
-
import {
|
|
17
|
-
import type
|
|
18
|
-
import { groupEntries } from '../../utils/array-grouping'
|
|
19
|
-
import { combineEventHandlers } from '../../utils/combine-event-handlers'
|
|
20
|
-
import {
|
|
21
|
-
pluginFacet,
|
|
22
|
-
type PluginPayload,
|
|
23
|
-
} from '../plugin'
|
|
6
|
+
import { defineFacetPayload } from '../../facets/facet-extension.ts'
|
|
7
|
+
import { defineFacet, type Facet } from '../../facets/facet.ts'
|
|
8
|
+
import type { PlainExtension } from '../../types/extension.ts'
|
|
9
|
+
import { groupEntries } from '../../utils/array-grouping.ts'
|
|
10
|
+
import { combineEventHandlers } from '../../utils/combine-event-handlers.ts'
|
|
11
|
+
import { pluginFacet, type PluginPayload } from '../plugin.ts'
|
|
24
12
|
|
|
25
13
|
export type KeyDownHandler = (
|
|
26
14
|
view: EditorView,
|
|
@@ -1,15 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import { createEditor } from '../../editor/editor'
|
|
9
|
-
import { union } from '../../editor/union'
|
|
10
|
-
import { defineTestExtension } from '../../testing'
|
|
11
|
-
|
|
12
|
-
import { defineFocusChangeHandler } from './focus'
|
|
1
|
+
import { describe, expect, it, vi } from 'vitest'
|
|
2
|
+
|
|
3
|
+
import { createEditor } from '../../editor/editor.ts'
|
|
4
|
+
import { union } from '../../editor/union.ts'
|
|
5
|
+
import { defineTestExtension } from '../../testing/index.ts'
|
|
6
|
+
|
|
7
|
+
import { defineFocusChangeHandler } from './focus.ts'
|
|
13
8
|
|
|
14
9
|
describe('defineFocusChangeHandler', () => {
|
|
15
10
|
it('should call the handler when the editor is focused or blurred', () => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { PlainExtension } from '../../types/extension'
|
|
1
|
+
import type { PlainExtension } from '../../types/extension.ts'
|
|
2
2
|
|
|
3
|
-
import { defineDomEventFacetPayload } from './dom-event'
|
|
3
|
+
import { defineDomEventFacetPayload } from './dom-event.ts'
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* A function that is called when the editor gains or loses focus.
|
|
@@ -1,17 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
PluginKey,
|
|
3
|
-
ProseMirrorPlugin,
|
|
4
|
-
type EditorState,
|
|
5
|
-
} from '@prosekit/pm/state'
|
|
1
|
+
import { PluginKey, ProseMirrorPlugin, type EditorState } from '@prosekit/pm/state'
|
|
6
2
|
import type { EditorView } from '@prosekit/pm/view'
|
|
7
3
|
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import type { PlainExtension } from '../../types/extension'
|
|
11
|
-
import {
|
|
12
|
-
pluginFacet,
|
|
13
|
-
type PluginPayload,
|
|
14
|
-
} from '../plugin'
|
|
4
|
+
import { defineFacetPayload } from '../../facets/facet-extension.ts'
|
|
5
|
+
import { defineFacet } from '../../facets/facet.ts'
|
|
6
|
+
import type { PlainExtension } from '../../types/extension.ts'
|
|
7
|
+
import { pluginFacet, type PluginPayload } from '../plugin.ts'
|
|
15
8
|
|
|
16
9
|
/**
|
|
17
10
|
* A function that is called when the editor view is mounted.
|
|
@@ -1,19 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
history,
|
|
3
|
-
redo,
|
|
4
|
-
undo,
|
|
5
|
-
} from '@prosekit/pm/history'
|
|
1
|
+
import { history, redo, undo } from '@prosekit/pm/history'
|
|
6
2
|
|
|
7
|
-
import { union } from '../editor/union'
|
|
8
|
-
import type { Extension } from '../types/extension'
|
|
9
|
-
import { isApple } from '../utils/env'
|
|
3
|
+
import { union } from '../editor/union.ts'
|
|
4
|
+
import type { Extension } from '../types/extension.ts'
|
|
5
|
+
import { isApple } from '../utils/env.ts'
|
|
10
6
|
|
|
11
|
-
import { defineCommands } from './command'
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
type Keymap,
|
|
15
|
-
} from './keymap'
|
|
16
|
-
import { definePlugin } from './plugin'
|
|
7
|
+
import { defineCommands } from './command.ts'
|
|
8
|
+
import { defineKeymap, type Keymap } from './keymap.ts'
|
|
9
|
+
import { definePlugin } from './plugin.ts'
|
|
17
10
|
|
|
18
11
|
const keymap: Keymap = {
|
|
19
12
|
'Mod-z': undo,
|
|
@@ -1,21 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
describe,
|
|
3
|
-
expect,
|
|
4
|
-
it,
|
|
5
|
-
} from 'vitest'
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
6
2
|
import { keyboard } from 'vitest-browser-commands/playwright'
|
|
7
3
|
|
|
8
|
-
import { union } from '../editor/union'
|
|
9
|
-
import type { TestEditor } from '../test'
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
defineParagraph,
|
|
13
|
-
defineText,
|
|
14
|
-
setupTestFromExtension,
|
|
15
|
-
} from '../testing'
|
|
16
|
-
import type { SelectionJSON } from '../types/model'
|
|
4
|
+
import { union } from '../editor/union.ts'
|
|
5
|
+
import type { TestEditor } from '../test/index.ts'
|
|
6
|
+
import { defineDoc, defineParagraph, defineText, setupTestFromExtension } from '../testing/index.ts'
|
|
7
|
+
import type { SelectionJSON } from '../types/model.ts'
|
|
17
8
|
|
|
18
|
-
import { defineBaseKeymap } from './keymap-base'
|
|
9
|
+
import { defineBaseKeymap } from './keymap-base.ts'
|
|
19
10
|
|
|
20
11
|
describe('Mod-a', () => {
|
|
21
12
|
it('can select the block for the first Mod-a press', async () => {
|
|
@@ -11,15 +11,12 @@ import {
|
|
|
11
11
|
} from '@prosekit/pm/commands'
|
|
12
12
|
import { splitSplittableBlock } from 'prosemirror-splittable'
|
|
13
13
|
|
|
14
|
-
import { selectBlockCommand } from '../commands/select-block'
|
|
15
|
-
import { withPriority } from '../editor/with-priority'
|
|
16
|
-
import type { PlainExtension } from '../types/extension'
|
|
17
|
-
import { Priority } from '../types/priority'
|
|
14
|
+
import { selectBlockCommand } from '../commands/select-block.ts'
|
|
15
|
+
import { withPriority } from '../editor/with-priority.ts'
|
|
16
|
+
import type { PlainExtension } from '../types/extension.ts'
|
|
17
|
+
import type { Priority } from '../types/priority.ts'
|
|
18
18
|
|
|
19
|
-
import {
|
|
20
|
-
defineKeymap,
|
|
21
|
-
type Keymap,
|
|
22
|
-
} from './keymap'
|
|
19
|
+
import { defineKeymap, type Keymap } from './keymap.ts'
|
|
23
20
|
|
|
24
21
|
// Replace `splitBlock` with `splitSplittableBlock`
|
|
25
22
|
const customEnter = chainCommands(
|
|
@@ -71,7 +68,7 @@ export interface BaseKeymapOptions {
|
|
|
71
68
|
* @public
|
|
72
69
|
*/
|
|
73
70
|
export function defineBaseKeymap({
|
|
74
|
-
priority = Priority.low,
|
|
71
|
+
priority = (1 satisfies typeof Priority.low),
|
|
75
72
|
preferBlockSelection = true,
|
|
76
73
|
}: BaseKeymapOptions = {}): BaseKeymapExtension {
|
|
77
74
|
const keymap: Keymap = {
|
|
@@ -1,27 +1,13 @@
|
|
|
1
1
|
import type { Command } from '@prosekit/pm/state'
|
|
2
|
-
import {
|
|
3
|
-
describe,
|
|
4
|
-
expect,
|
|
5
|
-
it,
|
|
6
|
-
vi,
|
|
7
|
-
} from 'vitest'
|
|
2
|
+
import { describe, expect, it, vi } from 'vitest'
|
|
8
3
|
import { keyboard } from 'vitest-browser-commands/playwright'
|
|
9
4
|
|
|
10
|
-
import { union } from '../editor/union'
|
|
11
|
-
import { withPriority } from '../editor/with-priority'
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
setupTest,
|
|
17
|
-
setupTestFromExtension,
|
|
18
|
-
} from '../testing'
|
|
19
|
-
import { Priority } from '../types/priority'
|
|
20
|
-
|
|
21
|
-
import {
|
|
22
|
-
defineKeymap,
|
|
23
|
-
type Keymap,
|
|
24
|
-
} from './keymap'
|
|
5
|
+
import { union } from '../editor/union.ts'
|
|
6
|
+
import { withPriority } from '../editor/with-priority.ts'
|
|
7
|
+
import { defineDoc, defineParagraph, defineText, setupTest, setupTestFromExtension } from '../testing/index.ts'
|
|
8
|
+
import { Priority } from '../types/priority.ts'
|
|
9
|
+
|
|
10
|
+
import { defineKeymap, type Keymap } from './keymap.ts'
|
|
25
11
|
|
|
26
12
|
describe('keymap', () => {
|
|
27
13
|
it('can register and unregister keymap', () => {
|
|
@@ -161,9 +147,9 @@ describe('keymap', () => {
|
|
|
161
147
|
]
|
|
162
148
|
|
|
163
149
|
for (const key of keybindings) {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
150
|
+
const command: Command = record(key)
|
|
151
|
+
const keymap: Keymap = { [key]: command }
|
|
152
|
+
const extension = defineKeymap(keymap)
|
|
167
153
|
editor.use(extension)
|
|
168
154
|
}
|
|
169
155
|
|
package/src/extensions/keymap.ts
CHANGED
|
@@ -1,22 +1,12 @@
|
|
|
1
1
|
import { keydownHandler } from '@prosekit/pm/keymap'
|
|
2
|
-
import {
|
|
3
|
-
Plugin,
|
|
4
|
-
PluginKey,
|
|
5
|
-
type Command,
|
|
6
|
-
} from '@prosekit/pm/state'
|
|
2
|
+
import { Plugin, PluginKey, type Command } from '@prosekit/pm/state'
|
|
7
3
|
import type { EditorView } from '@prosekit/pm/view'
|
|
8
4
|
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
} from '../facets/facet'
|
|
13
|
-
import { defineFacetPayload } from '../facets/facet-extension'
|
|
14
|
-
import type { PlainExtension } from '../types/extension'
|
|
5
|
+
import { defineFacetPayload } from '../facets/facet-extension.ts'
|
|
6
|
+
import { defineFacet, type Facet } from '../facets/facet.ts'
|
|
7
|
+
import type { PlainExtension } from '../types/extension.ts'
|
|
15
8
|
|
|
16
|
-
import {
|
|
17
|
-
pluginFacet,
|
|
18
|
-
type PluginPayload,
|
|
19
|
-
} from './plugin'
|
|
9
|
+
import { pluginFacet, type PluginPayload } from './plugin.ts'
|
|
20
10
|
|
|
21
11
|
/**
|
|
22
12
|
* A set of keybindings. Please read the
|
|
@@ -1,26 +1,11 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
} from '@prosekit/pm/model'
|
|
5
|
-
import formatHTML from 'diffable-html'
|
|
6
|
-
import {
|
|
7
|
-
describe,
|
|
8
|
-
expect,
|
|
9
|
-
it,
|
|
10
|
-
} from 'vitest'
|
|
1
|
+
import type { DOMOutputSpec, TagParseRule } from '@prosekit/pm/model'
|
|
2
|
+
import { formatHTML } from 'diffable-html-snapshot'
|
|
3
|
+
import { describe, expect, it } from 'vitest'
|
|
11
4
|
|
|
12
|
-
import { union } from '../editor/union'
|
|
13
|
-
import {
|
|
14
|
-
defineDoc,
|
|
15
|
-
defineParagraph,
|
|
16
|
-
defineText,
|
|
17
|
-
setupTestFromExtension,
|
|
18
|
-
} from '../testing'
|
|
5
|
+
import { union } from '../editor/union.ts'
|
|
6
|
+
import { defineDoc, defineParagraph, defineText, setupTestFromExtension } from '../testing/index.ts'
|
|
19
7
|
|
|
20
|
-
import {
|
|
21
|
-
defineMarkAttr,
|
|
22
|
-
defineMarkSpec,
|
|
23
|
-
} from './mark-spec'
|
|
8
|
+
import { defineMarkAttr, defineMarkSpec } from './mark-spec.ts'
|
|
24
9
|
|
|
25
10
|
describe('defineMarkSpec', () => {
|
|
26
11
|
it('can merge mark specs', () => {
|
|
@@ -1,26 +1,15 @@
|
|
|
1
|
-
import { mapGroupBy } from '@ocavue/utils'
|
|
2
|
-
import type {
|
|
3
|
-
AttributeSpec,
|
|
4
|
-
MarkSpec,
|
|
5
|
-
SchemaSpec,
|
|
6
|
-
} from '@prosekit/pm/model'
|
|
1
|
+
import { isNotNullish, mapGroupBy } from '@ocavue/utils'
|
|
2
|
+
import type { AttributeSpec, MarkSpec, SchemaSpec } from '@prosekit/pm/model'
|
|
7
3
|
import OrderedMap from 'orderedmap'
|
|
8
4
|
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import { schemaSpecFacet } from '../facets/schema-spec'
|
|
12
|
-
import type {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
} from '../
|
|
16
|
-
import
|
|
17
|
-
import { assert } from '../utils/assert'
|
|
18
|
-
import { mergeSpecs } from '../utils/merge-specs'
|
|
19
|
-
import {
|
|
20
|
-
wrapOutputSpecAttrs,
|
|
21
|
-
wrapParseRuleAttrs,
|
|
22
|
-
} from '../utils/output-spec'
|
|
23
|
-
import { isNotNullish } from '../utils/type-assertion'
|
|
5
|
+
import { defineFacetPayload } from '../facets/facet-extension.ts'
|
|
6
|
+
import { defineFacet } from '../facets/facet.ts'
|
|
7
|
+
import { schemaSpecFacet } from '../facets/schema-spec.ts'
|
|
8
|
+
import type { AnyAttrs, AttrSpec } from '../types/attrs.ts'
|
|
9
|
+
import type { Extension } from '../types/extension.ts'
|
|
10
|
+
import { assert } from '../utils/assert.ts'
|
|
11
|
+
import { mergeSpecs } from '../utils/merge-specs.ts'
|
|
12
|
+
import { wrapOutputSpecAttrs, wrapParseRuleAttrs } from '../utils/output-spec.ts'
|
|
24
13
|
|
|
25
14
|
/**
|
|
26
15
|
* @public
|
|
@@ -1,18 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
ProseMirrorPlugin,
|
|
4
|
-
} from '@prosekit/pm/state'
|
|
1
|
+
import { isNotNullish } from '@ocavue/utils'
|
|
2
|
+
import { PluginKey, ProseMirrorPlugin } from '@prosekit/pm/state'
|
|
5
3
|
import type { MarkViewConstructor } from '@prosekit/pm/view'
|
|
6
4
|
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import type { Extension } from '../types/extension'
|
|
10
|
-
import { isNotNullish } from '../utils/type-assertion'
|
|
5
|
+
import { defineFacetPayload } from '../facets/facet-extension.ts'
|
|
6
|
+
import { defineFacet } from '../facets/facet.ts'
|
|
7
|
+
import type { Extension } from '../types/extension.ts'
|
|
11
8
|
|
|
12
|
-
import {
|
|
13
|
-
pluginFacet,
|
|
14
|
-
type PluginPayload,
|
|
15
|
-
} from './plugin'
|
|
9
|
+
import { pluginFacet, type PluginPayload } from './plugin.ts'
|
|
16
10
|
|
|
17
11
|
/**
|
|
18
12
|
* @internal
|
|
@@ -1,17 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
PluginKey,
|
|
3
|
-
ProseMirrorPlugin,
|
|
4
|
-
} from '@prosekit/pm/state'
|
|
1
|
+
import { PluginKey, ProseMirrorPlugin } from '@prosekit/pm/state'
|
|
5
2
|
import type { MarkViewConstructor } from '@prosekit/pm/view'
|
|
6
3
|
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import type { Extension } from '../types/extension'
|
|
4
|
+
import { defineFacetPayload } from '../facets/facet-extension.ts'
|
|
5
|
+
import { defineFacet } from '../facets/facet.ts'
|
|
6
|
+
import type { Extension } from '../types/extension.ts'
|
|
10
7
|
|
|
11
|
-
import {
|
|
12
|
-
pluginFacet,
|
|
13
|
-
type PluginPayload,
|
|
14
|
-
} from './plugin'
|
|
8
|
+
import { pluginFacet, type PluginPayload } from './plugin.ts'
|
|
15
9
|
|
|
16
10
|
export interface MarkViewOptions {
|
|
17
11
|
name: string
|
|
@@ -1,29 +1,13 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
} from '
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
} from 'vitest'
|
|
12
|
-
|
|
13
|
-
import { union } from '../editor/union'
|
|
14
|
-
import {
|
|
15
|
-
defineDoc,
|
|
16
|
-
defineParagraph,
|
|
17
|
-
defineText,
|
|
18
|
-
setupTestFromExtension,
|
|
19
|
-
} from '../testing'
|
|
20
|
-
|
|
21
|
-
import { defineHistory } from './history'
|
|
22
|
-
import { defineBaseKeymap } from './keymap-base'
|
|
23
|
-
import {
|
|
24
|
-
defineNodeAttr,
|
|
25
|
-
defineNodeSpec,
|
|
26
|
-
} from './node-spec'
|
|
1
|
+
import type { DOMOutputSpec, Schema, TagParseRule } from '@prosekit/pm/model'
|
|
2
|
+
import { formatHTML } from 'diffable-html-snapshot'
|
|
3
|
+
import { describe, expect, it } from 'vitest'
|
|
4
|
+
|
|
5
|
+
import { union } from '../editor/union.ts'
|
|
6
|
+
import { defineDoc, defineParagraph, defineText, setupTestFromExtension } from '../testing/index.ts'
|
|
7
|
+
|
|
8
|
+
import { defineHistory } from './history.ts'
|
|
9
|
+
import { defineBaseKeymap } from './keymap-base.ts'
|
|
10
|
+
import { defineNodeAttr, defineNodeSpec } from './node-spec.ts'
|
|
27
11
|
|
|
28
12
|
describe('defineNodeSpec', () => {
|
|
29
13
|
it('can merge node specs', () => {
|
|
@@ -1,26 +1,15 @@
|
|
|
1
|
-
import { mapGroupBy } from '@ocavue/utils'
|
|
2
|
-
import type {
|
|
3
|
-
AttributeSpec,
|
|
4
|
-
NodeSpec,
|
|
5
|
-
SchemaSpec,
|
|
6
|
-
} from '@prosekit/pm/model'
|
|
1
|
+
import { isNotNullish, mapGroupBy } from '@ocavue/utils'
|
|
2
|
+
import type { AttributeSpec, NodeSpec, SchemaSpec } from '@prosekit/pm/model'
|
|
7
3
|
import OrderedMap from 'orderedmap'
|
|
8
4
|
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import { schemaSpecFacet } from '../facets/schema-spec'
|
|
12
|
-
import type {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
} from '../
|
|
16
|
-
import
|
|
17
|
-
import { assert } from '../utils/assert'
|
|
18
|
-
import { mergeSpecs } from '../utils/merge-specs'
|
|
19
|
-
import {
|
|
20
|
-
wrapOutputSpecAttrs,
|
|
21
|
-
wrapTagParseRuleAttrs,
|
|
22
|
-
} from '../utils/output-spec'
|
|
23
|
-
import { isNotNullish } from '../utils/type-assertion'
|
|
5
|
+
import { defineFacetPayload } from '../facets/facet-extension.ts'
|
|
6
|
+
import { defineFacet } from '../facets/facet.ts'
|
|
7
|
+
import { schemaSpecFacet } from '../facets/schema-spec.ts'
|
|
8
|
+
import type { AnyAttrs, AttrSpec } from '../types/attrs.ts'
|
|
9
|
+
import type { Extension } from '../types/extension.ts'
|
|
10
|
+
import { assert } from '../utils/assert.ts'
|
|
11
|
+
import { mergeSpecs } from '../utils/merge-specs.ts'
|
|
12
|
+
import { wrapOutputSpecAttrs, wrapTagParseRuleAttrs } from '../utils/output-spec.ts'
|
|
24
13
|
|
|
25
14
|
/**
|
|
26
15
|
* @public
|
|
@@ -1,18 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
ProseMirrorPlugin,
|
|
4
|
-
} from '@prosekit/pm/state'
|
|
1
|
+
import { isNotNullish } from '@ocavue/utils'
|
|
2
|
+
import { PluginKey, ProseMirrorPlugin } from '@prosekit/pm/state'
|
|
5
3
|
import type { NodeViewConstructor } from '@prosekit/pm/view'
|
|
6
4
|
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import type { Extension } from '../types/extension'
|
|
10
|
-
import { isNotNullish } from '../utils/type-assertion'
|
|
5
|
+
import { defineFacetPayload } from '../facets/facet-extension.ts'
|
|
6
|
+
import { defineFacet } from '../facets/facet.ts'
|
|
7
|
+
import type { Extension } from '../types/extension.ts'
|
|
11
8
|
|
|
12
|
-
import {
|
|
13
|
-
pluginFacet,
|
|
14
|
-
type PluginPayload,
|
|
15
|
-
} from './plugin'
|
|
9
|
+
import { pluginFacet, type PluginPayload } from './plugin.ts'
|
|
16
10
|
|
|
17
11
|
/**
|
|
18
12
|
* @internal
|
|
@@ -1,17 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
PluginKey,
|
|
3
|
-
ProseMirrorPlugin,
|
|
4
|
-
} from '@prosekit/pm/state'
|
|
1
|
+
import { PluginKey, ProseMirrorPlugin } from '@prosekit/pm/state'
|
|
5
2
|
import type { NodeViewConstructor } from '@prosekit/pm/view'
|
|
6
3
|
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import type { Extension } from '../types/extension'
|
|
4
|
+
import { defineFacetPayload } from '../facets/facet-extension.ts'
|
|
5
|
+
import { defineFacet } from '../facets/facet.ts'
|
|
6
|
+
import type { Extension } from '../types/extension.ts'
|
|
10
7
|
|
|
11
|
-
import {
|
|
12
|
-
pluginFacet,
|
|
13
|
-
type PluginPayload,
|
|
14
|
-
} from './plugin'
|
|
8
|
+
import { pluginFacet, type PluginPayload } from './plugin.ts'
|
|
15
9
|
|
|
16
10
|
export interface NodeViewOptions {
|
|
17
11
|
name: string
|